Apr 022013
 

How to redirect something like “www.example.orgto “www.example.com“, or “longer.subdomain.example.org” to “longer.subdomain.example.com” with a rewrite rule in nginx.conf:

What it does is, store everything that is in front of “.example.org” into the variable ‘name’ and rewrite the URL as ‘name’.example.com. $scheme is an nginx variable that contains the, well, URI scheme, i.e. protocol.

And one that is a little more complex:

Translates to “whatever matches (something dot (en or ro)) or starts with (en or ro) in front of ‘example.org’ will be stored into ‘name’ variable”. So basically it redirects any URL that has the language in it to come, but no other kind of subdomain gets redirected.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)