Redirect Without changing URL Apache

By | December 11, 2017

I want to redirect one URL to another without changing the Browser URL*).xml should redirect to$1

But the Browser should display*).xml


You can use a RewriteRule:

RewriteEngine On
RewriteRule /abc/(.*)\.xml$ /abc/xyz/index.htm?file=$1 [L]

Make sure you have mod_rewrite enabled and put this either in your VirtualHost config, or in a .htaccess file in your DocumentRoot


As Constantine posted on the accepted solution, the [P] flag is dangerous as it converts the server as a proxy.

See [this]:

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.

Leave a Reply

Your email address will not be published. Required fields are marked *