开发者

.htaccess (mod_rewrite) recursion in handling %{HTTP_HOST}

开发者 https://www.devze.com 2023-04-11 14:59 出处:网络
My aim is to simulate virtual hosts using mod_rewrite in .htaccess such that http://dog.animal.com maps internally to WEBROOT/public_html/dog/ , cat.animal.com maps internally to WEBROOT/public_html/c

My aim is to simulate virtual hosts using mod_rewrite in .htaccess such that http://dog.animal.com maps internally to WEBROOT/public_html/dog/ , cat.animal.com maps internally to WEBROOT/public_html/cat/ , where dog and cat are established usernames on the system.

I have (in an .htaccess in WEBROOT):

RewriteCond   %{HTTP_HOST}                 ^[^.]+\.animal\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^([^.]+)\.animal\.com(.*) /public_html/$1$2

But on requesting dog.animal.com I receive the following loop

Forbidden. You don't have permission to access /public_html/dogpublic_html/dogpublic_html开发者_C百科/dogpublic_html/dogpublic_html/..... etc etc

Clearly I am overlooking something stupidly obvious. I'd appreciate any pointers!

(I should say that in the above example, there are A records in teh zone file for the two subdomains)


In your second rewrite rule, you use /public_html which refers to root. Try removing the starting / or put the full path with WEBROOT

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号