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'm trying to read all the suggestions and tips that are present in this forum but I cant find a way to make this rule work. I want that if a specific url is requested that nginx redirect permanently to a subdomain:

if ($host = 'www.domain.com/zh/')

    redirect www.cn.domain.com$requested_uri

The syntax its not correct but its only to give the main idea, I only want that /zh/ jump to sub domain, the other like /en/, /jp/, etc. I don't want nginx make any redirect.

Thank you very much, all help will be very appreciated.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

This is pretty easy. You don't even need if.

rewrite ^/zh/(.*) http://www.cn.example.com/$1 permanent;
share|improve this answer
    
Worked perfectly. Thank you very much for the big help. Just one more question, if I can. What site or posts do you recommend regarding the nginx security, rules, pitfalls, etc? Thank you very much. –  pedro Jan 27 at 5:43
    
The nginx wiki? –  Michael Hampton Jan 27 at 5:44
    
Thank you very much! I found this one cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html , maybe can useful to other users. –  pedro Jan 27 at 6:24

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.