Apache RewriteRule – Proxy flag not working

.htaccessapache-2.2mod-proxy

I'm having a problem running Apache 2.2.20 on a Linux Mint distro.

I've got the following rule in my .htaccess file:

RewriteEngine on
RewriteRule old1/old2 http://localhost/new1 [P]

When I browse to http://localhost/old1/old2 I just get a redirect to localhost/new1. That is, the new URL shows in the address bar. I want the "old1/old2" URL to show (with the page content from /new1). What am I doing wrong?

I've installed mod_proxy and mod_proxy_http (i.e. a2enmod proxy, a2enmod proxy_http).

Best Answer

If both resources are on the same web-server, simply do an internal rewrite e.g.

RewriteEngine on
RewriteRule old1/old2 /new1 [L]