我想在不更改浏览器网址的情况下将一个网址重定向到另一个网址
www.example.com/abc /(.*)。xml应该重定向到www.example.com/abc/xyz/index.htm?file=$1
但浏览器应显示www.example.com/abc /(.*).xml
答案 0 :(得分:6)
您可以使用RewriteRule
:
RewriteEngine On
RewriteRule /abc/(.*)\.xml$ /abc/xyz/index.htm?file=$1 [L]
确保您已启用mod_rewrite
并将其放入VirtualHost
配置或.htaccess
DocumentRoot
文件中
答案 1 :(得分:0)
由于Constantine在接受的解决方案上发布,[P]标志很危险,因为它将服务器转换为代理。
P = Proxy. Forces the rule to be handled by mod_proxy. Transparently provide content from other servers, because your web-server fetches it and re-serves it. This is a dangerous flag, as a poorly written one will turn your web-server into an open-proxy and That is Bad.