【发布时间】:2011-07-04 05:06:58
【问题描述】:
我正在使用此代码将所有子域重定向到子域文件夹。 例如 test.site.com => site.com/test。
RewriteCond %{HTTP_HOST} !^www\.site\.com [NC]
RewriteCond %{HTTP_HOST} ([^.]+)\.site\.com [NC]
RewriteRule ^(.*)$ http://site.com/%1 [L]
当我访问 test.site.com 时,它会自动重定向到文件夹 test/。我想留在域 test.site.com 并显示 test/ 文件夹的内容,而不重定向到实际文件夹。谢谢。
【问题讨论】:
-
这是不可能的。在 mod_rewrite 中,如果 HOST_NAME 正在更改,则它必须是外部重定向,并且浏览器中的 URL 将更改以显示新的 HOST_NAME。
标签: .htaccess redirect subdomain