我想将一个URL重定向到另一个URL,但不改变浏览器中的URL。
www.example.com/abc/(.*).xml 应该重定向到 www.example.com/abc/xyz/index.htm?file=$1
但是浏览器应该显示 www.example.com/abc/(.*).xml
我想将一个URL重定向到另一个URL,但不改变浏览器中的URL。
www.example.com/abc/(.*).xml 应该重定向到 www.example.com/abc/xyz/index.htm?file=$1
但是浏览器应该显示 www.example.com/abc/(.*).xml
RewriteRule
:RewriteEngine On
RewriteRule /abc/(.*)\.xml$ /abc/xyz/index.htm?file=$1 [L]
请确保您已启用mod_rewrite
并将其放置在您的VirtualHost
配置文件中或在您的DocumentRoot
中的.htaccess
文件中。
就像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.