0

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.

1 Answer 1

1

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

rewrite ^/zh/(.*) http://www.cn.example.com/$1 permanent;
3
  • 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, 2014 at 5:43
  • The nginx wiki? Jan 27, 2014 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, 2014 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .