domain rewrite/redirect

chiefops nginx-forum at
Tue May 3 02:35:50 MSD 2011

I have two different domains. One is a shortened url for referrals.   I
want to be able redirect the host name from the short url with
parameters to the actual url.  For example:

rewrite/redirect to

Initially I used a CNAME setup for to rewrite to but
that doesn't rewrite the domain name or url.

Here's a short version of my setup with the rewrite rules I'm trying to

http {
   server {
      listen 80;
      rewrite ^(.*) https://$host$1 permanent;

   server {
      listen 443;
      if ($host ~* ^(efgh\.com)$ ) {
         rewrite ^/(.*)$$ redirect;

The url on the user's browser after entering
should appear as  Currently, it's
just rewriting.

Posted at Nginx Forum:,195075,195075#msg-195075

More information about the nginx mailing list