Forum: NGINX 301 Redirect Domain

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
38d8cf48c4f1fb7a87cf4b02d8a16b8d?d=identicon&s=25 Chris Wilson (mindhunter77)
on 2009-05-25 22:30
Is there a way to redirect and old domain to a new one,

For instance, all I did was change domains, the structure is all still
the same.

I just need to redirect xxxx.com to xxxy.com while still keeping the
structure of the incoming links as they remain in the same pace on the
new site.
96dfd0f0a8399d3b03feba1e6a562e0a?d=identicon&s=25 Edho P Arief (Guest)
on 2009-05-25 22:50
(Received via mailing list)
On Tue, May 26, 2009 at 3:30 AM, Chris Wilson <lists@ruby-forum.com>
wrote:
>
>

something like this?

server {
       listen                          <ipaddress/port>;
       server_name                             oldadress.com;
       rewrite         ^(.*)$  http://newaddress.com$1 permanent;
}
2c6f80fff253635f12c249ef4f116796?d=identicon&s=25 Jim Ohlstein (Guest)
on 2009-05-25 22:50
(Received via mailing list)
Chris Wilson wrote:
> Is there a way to redirect and old domain to a new one,
>
> For instance, all I did was change domains, the structure is all still
> the same.
>
> I just need to redirect xxxx.com to xxxy.com while still keeping the
> structure of the incoming links as they remain in the same pace on the
> new site.
>

server {

    listen 80;

    server_name xxxx.com www.xxxx.com;

    ...

    rewrite  ^  http://yyyy.com$request_uri? permanent;

}

should do it.



If you want to get fancy you can separate out like:

server {

    listen 80;

    server_name xxxx.com;

    ...

    rewrite  ^  http://yyyy.com$request_uri? permanent;

}

server {

    listen 80;

    server_name www.xxxx.com;

    ...

    rewrite  ^  http://www.yyyy.com$request_uri? permanent;

}

Jim
38d8cf48c4f1fb7a87cf4b02d8a16b8d?d=identicon&s=25 Chris Wilson (mindhunter77)
on 2009-05-25 23:32
Thanks guys, that worked!
This topic is locked and can not be replied to.