# Redirect old domain to new domain

**URL:** <https://www.ruby-forum.com/t/redirect-old-domain-to-new-domain/201380>\
**Category:** NGINX\
**Created:** [January 6, 2011, 10:47am UTC](https://www.ruby-forum.com/t/redirect-old-domain-to-new-domain/201380 "2011-01-06T10:47:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [January 6, 2011, 10:47am UTC](https://www.ruby-forum.com/t/redirect-old-domain-to-new-domain/201380/1 "2011-01-06T10:47:38Z")

</div>

Hi,

I have an old domain & new domain, let’s call the old domain is  
[www.olddomain.com](http://www.olddomain.com) and the new one is [www.newdomain.com](http://www.newdomain.com).  
Yesterday, I’ve register the new domain ([www.newdomain.com](http://www.newdomain.com)), but, the  
[olddomain.com](http://olddomain.com) still active. Both of them can be accessed by user. But,  
in  
some direction (nginx.conf), i’ve limit the old domain can accessed some  
directory, but the new domain can access all directory in public\_html.

Could nginx make a rules, if the user access the site from  
[olddomain.com](http://olddomain.com),  
for example, the user access a file from [www.olddomain.com/file.exe](http://www.olddomain.com/file.exe),  
will be  
redirected automatically to [Parked at Loopia](http://www.newdomain.com/file.exe). NginX Wiki  
doesn’t  
provide this documentation. ☹

## Thanks, antituhan

View this message in context:  
[http://nginx.2469901.n2.nabble.com/ASK-Redirect-old-domain-to-new-domain-tp5894964p5894964.html](http://nginx.2469901.n2.nabble.com/ASK-Redirect-old-domain-to-new-domain-tp5894964p5894964.html)  
Sent from the nginx mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [January 6, 2011, 11:00am UTC](https://www.ruby-forum.com/t/redirect-old-domain-to-new-domain/201380/2 "2011-01-06T11:00:49Z")

</div>

On 1/6/11 4:46 AM, antituhan wrote:

> Could nginx make a rules, if the user access the site from [olddomain.com](http://olddomain.com),  
> for example, the user access a file from [www.olddomain.com/file.exe](http://www.olddomain.com/file.exe), will be  
> redirected automatically to [Parked at Loopia](http://www.newdomain.com/file.exe). NginX Wiki doesn’t  
> provide this documentation. ☹

server {  
listen 80;  
server\_name [www.olddomain.com](http://www.olddomain.com);  
rewrite ^ http://newdomain.com$request\_uri? permanent;  
}

> Thanks,  
> antituhan

–  
Jim O.

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [January 6, 2011, 3:53pm UTC](https://www.ruby-forum.com/t/redirect-old-domain-to-new-domain/201380/3 "2011-01-06T15:53:29Z")

</div>

Hi jim,

## thank you very much 🙂 works like a charm 🙂

View this message in context:  
[http://nginx.2469901.n2.nabble.com/ASK-Redirect-old-domain-to-new-domain-tp5894964p5895783.html](http://nginx.2469901.n2.nabble.com/ASK-Redirect-old-domain-to-new-domain-tp5894964p5895783.html)  
Sent from the nginx mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![antituhan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6bbea6/32.png) [@antituhan](https://www.ruby-forum.com/u/antituhan)\
**Post date:** [January 6, 2011, 11:02am UTC](https://www.ruby-forum.com/t/redirect-old-domain-to-new-domain/201380/4 "2011-01-06T11:02:42Z")

</div>

On 1/6/11 4:59 AM, Jim O. wrote:

> > 
> 
> rewrite ^ http://newdomain.com$request\_uri? permanent;  
> }

- rewrite ^ http://newdomain.com$request\_uri? permanent;

- rewrite ^ http://www.newdomain.com$request\_uri? permanent;

> > Thanks,  
> > antituhan

–  
Jim O.
