Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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(.*) http://admin.example.com$uri permanent;
     }

Thank you Regards

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Something like this should do the job:

location ^~ /admin/ {
    rewrite ^/admin/(.*) http://admin.example.com/$1 permanent;
}
share|improve this answer
    
Thanks for reply. I've changed a bit to optimize it: rewrite ^ http://admin.example.com/login.php$1 permanent;. I would like to also set another redirection from http://admin.exmaple.com to http://admin.example.com/login.php. 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

 
discard

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.