Welcome to WebmasterWorld Guest from 54.211.86.24

Forum Moderators: Ocean10000 & incrediBILL & phranque

Trying to redirect sub folder as root with .htaccess

none www redirect not working

   
11:28 am on Nov 19, 2013 (gmt 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



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]
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month