# 301 Redirect Domain

**URL:** <https://www.ruby-forum.com/t/301-redirect-domain/168786>\
**Category:** NGINX\
**Created:** [May 25, 2009, 10:30pm UTC](https://www.ruby-forum.com/t/301-redirect-domain/168786 "2009-05-25T22:30:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [May 25, 2009, 10:30pm UTC](https://www.ruby-forum.com/t/301-redirect-domain/168786/1 "2009-05-25T22:30:33Z")

</div>

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](http://xxxx.com) to [xxxy.com](http://xxxy.com) while still keeping the  
structure of the incoming links as they remain in the same pace on the  
new site.

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [May 25, 2009, 10:50pm UTC](https://www.ruby-forum.com/t/301-redirect-domain/168786/2 "2009-05-25T22:50:50Z")

</div>

On Tue, May 26, 2009 at 3:30 AM, Chris W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 

something like this?

server {  
listen \<ipaddress/port\>;  
server\_name [oldadress.com](http://oldadress.com);  
rewrite ^(.\*)$ [http://newaddress.com$1](http://newaddress.com$1) permanent;  
}

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [May 25, 2009, 10:50pm UTC](https://www.ruby-forum.com/t/301-redirect-domain/168786/3 "2009-05-25T22:50:51Z")

</div>

Chris W. 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](http://xxxx.com) to [xxxy.com](http://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

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [May 25, 2009, 11:32pm UTC](https://www.ruby-forum.com/t/301-redirect-domain/168786/4 "2009-05-25T23:32:59Z")

</div>

Thanks guys, that worked!
