[英].htaccess redirect from subdirectory to another domain with proxy
I have the following 2 directories.com 我有以下2个directories.com
http://www.site1.com/dir http://www.site2.com/dir http://www.site1.com/dir http://www.site2.com/dir
I want all traffic to http://www.site1.com/dir to redirect to http://www.site2.com while keeping http://www.site1.com/dir in the address bar. 我希望http://www.site1.com/dir的所有流量都重定向到http://www.site2.com,同时在地址栏中保留http://www.site1.com/dir 。 I have mod_proxy enabled, but I can't figure out the proper lines to put into the .htaccess file.
我启用了mod_proxy,但我无法找出放入.htaccess文件的正确行。
On www.site1.com
enable mod_rewrite
and .htaccess
through httpd.conf
and then put this code in your DOCUMENT_ROOT/.htaccess
file: 在
www.site1.com
通过httpd.conf
启用mod_rewrite
和.htaccess
,然后将此代码放入DOCUMENT_ROOT/.htaccess
文件中:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.com$ [NC]
RewriteRule ^(dir1/.*)$ http://www.site2.com/$1 [L,NC,P]
P
flag here will make use of mod_proxy
and make www.site1.com
act as proxy server to forward request from www.site2.com
. 此处的
P
标志将使用mod_proxy
并使www.site1.com
充当代理服务器以转发来自www.site2.com
请求。 URL will not change in browser. 浏览器中的URL不会更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.