开发者

Help with htaccess redirect for subdomain

开发者 https://www.devze.com 2023-03-13 03:22 出处:网络
I\'m using this code to redirect all subdomains to the subdomain folder. For example test.site.com => s开发者_Python百科ite.com/test.

I'm using this code to redirect all subdomains to the subdomain folder. For example test.site.com => s开发者_Python百科ite.com/test.

RewriteCond %{HTTP_HOST} !^www\.site\.com [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.site\.com [NC]
RewriteRule ^(.*)$ http://site.com/%1 [L]

When I visit test.site.com it automatically redirects to the folder test/.I want to stay at the domain test.site.com and show the contents of test/ folder without redirecting to the actuall folder.Thanks.


You could do achive that with this code:

RewriteCond %{HTTP_HOST} !^www\.site\.com [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.site\.com [NC]
RewriteRule ^(.*)$ /%1/$1 [L]
0

精彩评论

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