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 have the current rule for my nginx routes:

        listen   80;
        rewrite ^/(.*)$1 permanent;

This works but only for the root path and not other routes. For example, a route like gets redirected to How do ensure that gets routes to

I got this to work by adding a '$' at the end:

rewrite ^/(.*)$$1 permanent;

share|improve this question

The rewrite you have there actually should work. That said, you don't need the capture at all as Nginx has already done that for you. You can just use

rewrite ^$request_uri? permanent;
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.