Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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).

share|improve this question

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

RewriteEngine on
RewriteRule old1/old2 /new1 [L]
share|improve this answer
This would mean /new1 was visible in the URL wouldn't it? I want to fetch data from /new1 but display the requested URL old1/old2 ? – Monkeybrain Jan 18 '13 at 14:34
No, the old URL will remain visible, as an INTERNAL not a CLIENT rewrite. – arober11 Jan 18 '13 at 14:44
Just tried that and unfortunately I'm not seeing that happening - the browser gets the /new1 page but also the /new1 URL. – Monkeybrain Jan 18 '13 at 14:54
The above syntax will perform an internal rewrite (does not alter the URL in the browser), so try another browser flavour. If the rule still doesn't work an earlier rule or syntax error is likely to be at fault, in your config. If your other browser works as expected, clear the browser cache on the other browser, and re-test. See: Rewriting From Old to New (external) – arober11 Jan 18 '13 at 15:39
That's a useful link, thanks. It does seem to be saying the opposite though - From Old To New (Internal) uses the [PT] flag, which doesn't change the URL in the browser, while From Old To New (External) does not specify the proxy flag, and therefore the URL does change in the browser. Therefore I need to use the proxy flag [P] ? – Monkeybrain Jan 18 '13 at 15:57

I think you also need a ProxyPassReverse statement. Here's an example from

RewriteEngine  on
RewriteBase    /products/
RewriteRule    ^widget/(.*)$$1  [P]
ProxyPassReverse /products/widget/
share|improve this answer
Unfortunately this needs to be done in a .htaccess file, where ProxyPassReverse is not permitted. – Monkeybrain Jan 18 '13 at 14:44

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

If doesn't work try change "localhost" to "localhost:80".

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.