繁体   English   中英

.htaccess点文件夹到其他IP

[英].htaccess point folder to other IP

我发现了其他几个问题,但这些都不是我要尝试做的。

我需要点www.mywebsite.com/ certainfolder /布拉布拉/?富=栏要www.anotherwebsite.com/ certainfolder /布拉布拉/?富=酒吧

因此,如果我的网站具有通往“ certainfolder”的路径,则需要指向该文件夹(以及所有其他uri分段和获取参数),指向另一个网站。

重要的是该URL仍为www.mywebsite.com/certainfolder/blabla/?foo=bar它仅需从www.anotherwebsite.com中获取内容,但不能更改该URL。

我尝试了类似的方法,但无法正常工作:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/certainfolder
RewriteRule ^/$ http://www.anotherwebsite.com/certainfolder/$1 [P,L]

我知道我可以在vhost conf文件中使用ProxyPass和ProxyPassReverse,但是我无法访问此文件,因此我需要在.htaccess中进行操作

有什么.htaccess专家可以帮助我吗?

假设网站未自行重定向,则可以RewriteEngine on RewriteRule ^certainfolder/$ http://www.anotherwebsite.com/certainfolder/$1 [P] certainfolder RewriteEngine on RewriteRule ^certainfolder/$ http://www.anotherwebsite.com/certainfolder/$1 [P]使用mod_proxy + mod_proxy_http(/ http2) RewriteEngine on RewriteRule ^certainfolder/$ http://www.anotherwebsite.com/certainfolder/$1 [P]

[P]仅在启用mod_proxy时有效,并且对于http来说,mod_proxy_http是必需的。

mod_proxy允许将来自另一个资源的请求“代理”到您自己的域。

仅在您自己的主机上才需要mod_proxy,而在远程部分则不需要。 mod_proxy_http是处理针对mod_proxy的http请求的部分。 (因为mod_proxy还可以提供http以外的其他协议,因此已将其模块化)。 在通用Linux安装命令行上,输入: a2enmod proxy proxy_http && service apache2 restart

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM