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 know about the HttpRewriteModule, but I don't really know how to handle regex and I would need to redirect all URLs within a certain directory to another, specifically


Could some one tell me how to do this in Nginx?

share|improve this question
up vote 18 down vote accepted

Do you mean something like:

rewrite ^/component(.*)$ $1 last;
share|improve this answer
I think this will do it, thank you so much. I'm awful at regular expressions; I will have to try to learn them... – javipas Aug 18 '11 at 12:05 has explanation on the right side – Jon Mar 25 '15 at 11:13
You may need to replace last by break. (Last will try to resolve other locations after the rewrite). – Thomas Decaux Apr 11 '15 at 9:57

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.