1753754 Members
4970 Online
108799 Solutions
New Discussion

Apache RewriteRule

 
RobinKing
Valued Contributor

Apache RewriteRule

Looking for some help with what I would have though was a simple RewriteRule, but this is the first time I've had to do it.

A few sites we have are all under a single context root, so:

www.domain.com/root/site1
www.domain.com/root/site2
www.domain.com/root/site3

I want users to be able to hit www.domain.com/site1 and be forwarded. If this can be done without changing the URL in the browser then even better.

I've got as far as:

RewriteRule ^/(.*)$ /root/$1 [PT]

This redirects the first page fine, but if you hit any links in the web page they obviously still have the original context root, so this rule adds /root to it again, and the page cannot be found:

www.domain.com/root/site1/page1 becomes www.domain.com/root/root/site1/page1 and 404s.

I'm obviously missing something fundamental but mod-rewrite seems like a mine field.

Thanks!