0

I have this folder structure

webroot/
    www/
    srv/

When I visit http://www.domain.com, it points to the www/ folder using this codes:

RewriteCond %{HTTP:Host} ^(?:www\.)?domain\.com$
RewriteRule (.*) /www/$1 [NC,L,NS]

It shows the contents of the www/ folder without the folder name on the address bar. It retains its name to:

http://www.domain.com

What I want is to use the .htaccess mod_rewrite to change from:

http://sub.domain.com

to

http://sub.domain.com/srv

Where it shows the sub folder and it contents. Is it possible? I tried:

RewriteCond %{HTTP:Host} ^(?:sub\.domain\.com)?$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/srv/$1 [R=301,L]

but it returns a redirect loop error. How can I do this?

4

1 回答 1

0

您需要检查它是否已经指向/srv. 尝试:

RewriteCond %{HTTP:Host} ^(?:sub\.domain\.com)?$
RewriteCond %{REQUEST_URI} !^/srv/
RewriteRule ^(.*)$ http://%{HTTP_HOST}/srv/$1 [R=301,L]
于 2012-12-27T07:19:44.707 回答