且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重定向一个子域到另一个域的子文件夹,并保持该子域的网址

更新时间:2022-12-09 11:23:54

您正在使用[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]