如何将htaccess文件写入通配符2级文件夹到子域

时间:2014-12-28 05:18:58

标签: .htaccess rewrite rule

如何重写此

www.mywebsite.com/folder/folder1到folder1.mywebsite.com /

www.mywebsite.com/folder/folder2到folder2.mywebsite.com /

www.mywebsite.com/folder/folder3到folder3.mywebsite.com /

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.mywebsite\.com$
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%1%{REQUEST_URI} -d
RewriteRule ^((?!folder/).*)$ /folder/%1/$1 [L]