Welcome to WebmasterWorld Guest from

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Trying to redirect sub folder as root with .htaccess

none www redirect not working

11:28 am on Nov 19, 2013 (gmt 0)

Junior Member

joined:Feb 19, 2012
posts: 54
votes: 0

I'm using the .htaccess below to try to get my site to appear to be in the root, even though it is in the magento directory.

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.org\.uk$
RewriteCond %{REQUEST_URI} !^/magento/
RewriteRule ^(.*)$ /magento/$1

It all works great until I try to enter the site with the none www. prefix. If I type in http://example.org.uk I'm getting the error below

403 Forbidden
Access to this resource on the server is denied! Powered By LiteSpeed Web Server

Could it be a server or lightspeed setting that's stopping this working properly?

Many thanks in advance for your help, John

[edited by: phranque at 8:36 pm (utc) on Nov 19, 2013]
[edit reason] Please Use example.com [webmasterworld.com] [/edit]

8:47 pm on Nov 19, 2013 (gmt 0)


WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
votes: 15

RewriteCond %{HTTP_HOST} ^www\.example\.org\.uk$

It all works great until I try to enter the site with the none www. prefix.

get rid of that RewriteCond - in your case hostname should be irrelevant at this point.
before that internal rewrite to the magento directory, you want to do an external redirect to the root directory when the /magento/ path is requested.
this redirect should include the fully qualified canonical protocol and hostname in the target.
after this redirect and before the internal rewrite(s), you need another canonical hostname redirect to handle requests for other url paths.
and maybe another one before that for index directory document requests.

you might want to read this thread - Canonicalization: best code to redirect no-www to www & index to /:
http://www.webmasterworld.com/apache/4508251.htm [webmasterworld.com]

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members