homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Trying to redirect sub folder as root with .htaccess
none www redirect not working
wokka




msg:4624459
 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]

 

phranque




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

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]

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved