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

I would like to redirect admin subdirectory to a subdomain. I tried to create this rule for Nginx however it's not working:

location ^~ /admin/ {
        rewrite ^/admin(.*)$uri permanent;

Thank you Regards

share|improve this question
up vote 4 down vote accepted

Something like this should do the job:

location ^~ /admin/ {
    rewrite ^/admin/(.*)$1 permanent;
share|improve this answer
Thanks for reply. I've changed a bit to optimize it: rewrite ^$1 permanent;. I would like to also set another redirection from to Do I have to set another "location" or there is any better way to achive this. Will this cause any loops?. Thank you – HTF Jun 6 '12 at 12:29

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.