Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

What is the difference between using mod_proxy and mod_rewrite?

I have a requirement to send certain url patterns through the tomcat, which runs on the same host but under port 8080. I know this is something for mod_proxy, but I"m wondering why I can't just use mod_rewrite, or what the difference is?

Probably has to do w/ reverse proxy, and also when in the pipeline it gets handled?


share|improve this question
up vote 4 down vote accepted

mod_rewrite using the P flags puts the request through mod_proxy. The advantage in using mod_rewrite is that you get more control for mapping requests, just like rewrite let's you rewrite URLs. But the proxying is exactly the same. The disadvantage is that mod_rewrite syntax is more complex. So my recommendation is to use mod_proxy -style configuration directives unless you need something more complicated. Others will probably recommend mod_rewrite -style, because then you only have to learn one style.

share|improve this answer
As ptman already mentioned, with mod_rewrite you can do crazy stuff like dynamic routing to a proxy. This is sometimes very handy and you can connect to a proxy-cluster with one command instead of multiple mod_proxy lines. But is more complex and sometime not easy to debug. – DrDol Sep 25 '10 at 10:15

mod_rewrite is very general and very powerful: it can handle not only proxying but also aliasing, redirection, and pretty much any sort of custom mapping of URLs to either other URLs or filenames. (Well, I suppose if you looked hard enough you could find something mod_rewritecan't do) But there are several potential reasons not to use it:

  • You might not want to deal with the complexity of mod_rewrite. It is notoriously tricky to configure properly - the configuration is practically a programming language in itself.
  • Apache takes time to process all those complex rewriting rules, and if you have a busy server that may be something you don't want to deal with. Using mod_proxy directly allows you to invoke more streamlined code that might help your server run faster. (Honestly, I'm not sure how large of an effect this is, but I don't think it's that major)
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.