Nginx Specific Redirect Rules

pedro asked:

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.

My answer:

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

rewrite ^/zh/(.*)$1 permanent;

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.