我想一个子域,说 http://sub.domain.com 重定向到另一个域的如 https://unrelatedsub.otherdomain.com/domain.com/ 以及所有子文件夹内侧,从而 https://unrelatedsub.otherdomain.com/domain.com /:/ U / R / L /文件可以转到 HTTP访问/sub.domain.com/u/r/l/file
I'd like to redirect a subdomain, say http://sub.domain.com to another domain's subfolder like https://unrelatedsub.otherdomain.com/domain.com/ as well as everything inside, so that https://unrelatedsub.otherdomain.com/domain.com/u/r/l/file can be accessed by going to http://sub.domain.com/u/r/l/file
另外,如果有可能,在浏览器的地址栏应该显示的子域名的URL( HTTP ://sub.domain.com/u/r/l/file )
Also, if it is possible, the browser's address bar should display the subdomain's url (http://sub.domain.com/u/r/l/file)
在寻求解决办法,我就翻过了这种可能性
While searching for solutions, I came accross this possibility
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/ (子不该 T为中),并没有隐藏的网址。
However, in this case, accessing http://sub.domain.com/ redirects to https://unrelatedsub.otherdomain.com/domain.com/sub/ (sub shouldn't be in) and doesn't "hide" the URL.
推荐答案
您正在使用[R]标志,这意味着外部重定向,即在地址栏上的地址。如果你有的mod_proxy
加载,您可以使用[P]标志,这将导致apache httpd的服务器来代理请求,即URL在地址栏中停留。
You're using the [R] flag which means external redirect, i.e. the address in the address bar changes. If you have mod_proxy
loaded, you can use the [P] flag which causes the apache httpd server to proxy the requests, i.e. the url in the address bar stays.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [NC]
RewriteRule ^(.*) https://unrelatedsub.otherdomain.com/domain.com/$1 [P]
相关推荐
最新文章