Sign up ×
Server Fault is a question and answer site for 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 = '')


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/(.*)$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 '14 at 5:43
The nginx wiki? – Michael Hampton Jan 27 '14 at 5:44
Thank you very much! I found this one , maybe can useful to other users. – pedro Jan 27 '14 at 6:24

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.