I have a rewrite that changes my DocumentRoot from /public_html
to /public_html/MAIN
and it works great.
RewriteRule ^$ /MAIN/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/MAIN/
RewriteRule ^(.*)$ /MAIN/$1
Now If I try to add the following instruction to always show the www
subdomain, it no longer behaves properly...
RewriteCond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [r=301,nc]
Visiting http://domain.com/
causes a rewrite to http://www.domain.com/M开发者_运维百科AIN/
which is not what I want. I do not want the MAIN
subdirectory to be visible.
What am I missing?
The ^(.*)$
pattern captures the current URI, no matter it's in the location bar or it's an internal redirection. One of these solutions should work:
- Put the subdomain redirection first
- Replace
$1
with a variable, e.g.%{REQUEST_URI}
精彩评论