【发布时间】:2014-10-09 17:00:15
【问题描述】:
我想重定向一个子域,例如 http://sub.domain.com 到另一个域的子文件夹,例如 https://unrelatedsub.otherdomain.com/domain.com/ 以及其中的所有内容,以便可以通过转到 http://sub.domain.com/u/r/l/file 来访问 https://unrelatedsub.otherdomain.com/domain.com/u/r/l/file
另外,如果可能的话,浏览器的地址栏应该显示子域的 url (http://sub.domain.com/u/r/l/file)
在寻找解决方案时,我遇到了这种可能性
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^(.*) https://unrelatedsub.otherdomain.com/domain.com/$1 [L,R]
但是,在这种情况下,访问 http://sub.domain.com/ 会重定向到 https://unrelatedsub.otherdomain.com/domain.com/sub/(不应该在其中)并且不会“隐藏” URL。
【问题讨论】:
标签: .htaccess mod-rewrite redirect subdomain