Domain rewrite/redirect

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

efgh.com/referrals/123456

Initially I used a CNAME setup for adbcd.com to rewrite to efgh.com 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
use:

http {
server {
listen 80;
server_name abcd.com efgh.com;
rewrite ^(.*) https://$host$1 permanent;
}

server {
listen 443;
server_name abcd.com efgh.com;
if ($host ~* ^(efgh.com)$ ) {
rewrite ^/(.*)$ https://abcd.com/referrals/$ redirect;
}
}
}

The url on the user’s browser after entering https://efgh.com/123456
should appear as https://abcd.com/referrals/123456. Currently, it’s
just rewriting.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,195075,195075#msg-195075

I think I’m getting a bit further.

I modified this a bit and its redirecting but not carrying the
parameters. Here’s the updated config:

http {
server {
listen 80;
server_name abcd.com;
rewrite ^(.) https://$host$1 permanent;
}
server {
listen 80;
server_name efgh.com;
rewrite ^(.
) https://abcd.com/referrals/$1 redirect;
}
server {
listen 443;
server_name abcd.com;
}
server {
listen 443;
server efgh.com
rewrite ^(.*) https://abcd.com/referrals/$1 permanent;
}
}
}
}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,195075,195084#msg-195084

On Mon, 02 May 2011 19:55:11 -0400
“chiefops” [email protected] wrote:

http://nginx.org/mailman/listinfo/nginx
Hello,

You may also use HSTS headers to ensure your users use SSL instead of
non-SSL. This won’t replace the redirect, but the compatible browser
will know on the next visit that it should use the SSL server only. It
won’t request the non-SSL part.

More about HSTS:
https://secure.wikimedia.org/wikipedia/en/wiki/HTTP_Strict_Transport_Security

Cheers,

C.

Nevermind, got if fixed on my end. Simple, just had to reread the wiki:

rewrite ^ https://abcd.com/referrals$request_uri? permanent;

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,195075,195093#msg-195093

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs