我在Linux Mint发行版上运行Apache 2.2.20时遇到问题。
我的.htaccess文件中有以下规则:
RewriteEngine on RewriteRule old1/old2 http://localhost/new1 [P]
当我浏览到http://localhost/old1/old2我只是redirect到localhost/new1 。 也就是说,新的URL显示在地址栏中。 我想显示“old1 / old2”的url(来自/ new1的网页内容)。 我究竟做错了什么?
我已经安装了mod_proxy和mod_proxy_http(即a2enmod proxy , a2enmod proxy_http )。
如果两个资源都在同一个Web服务器上,那么只需进行内部重写即可
RewriteEngine on RewriteRule old1/old2 /new1 [L]
我想你也需要一个ProxyPassReverse语句。 这里是http://httpd.apache.org/docs/2.4/rewrite/proxy.html的一个例子
RewriteEngine on RewriteBase /products/ RewriteRule ^widget/(.*)$ http://product.example.com/widget/$1 [P] ProxyPassReverse /products/widget/ http://product.example.com/widget/
RewriteEngine on RewriteRule ^old1/old2*$ http://localhost/new1 [P] RewriteRule ^old1/old2/*$ http://localhost/new1 [P]
如果不起作用,请将“localhost”更改为“localhost:80”。