# Moving from one dns domain to another

**URL:** <https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340>\
**Category:** Rails\
**Created:** [October 7, 2008, 3:35pm UTC](https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340 "2008-10-07T15:35:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [October 7, 2008, 3:35pm UTC](https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340/1 "2008-10-07T15:35:18Z")

</div>

My Rails 2.1 app is changing DNS domains. For example:  
From: [www.oldcompany.com](http://www.oldcompany.com)  
To: [www.newcompany.com](http://www.newcompany.com)  
The app uses Apache2, mongrel\_cluster, MySQL.  
I would like the existing users who visit [www.oldcompany.com](http://www.oldcompany.com) URLs to be:

1. Notified via an HTML page that the site has changed from oldcompany  
to new company and then redirect them to newcompany.  
This has to be done on the same server which gets new host name etc.

I know that it can be done with mod\_rewrite, but I am not proficient  
with it. Is there a rewrite rule that I can put into my httpd.conf file  
that will detect the incoming URLs with oldcompany hostnames and  
redirect them to a particular HTML page?  
For some time, I can keep both the new and old DNS names pointed to the  
same IP address.  
Thanks.  
Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [October 7, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340/2 "2008-10-07T15:59:58Z")

</div>

On 07 Oct 2008, at 15:35, Bharat R. wrote:

> I know that it can be done with mod\_rewrite, but I am not proficient  
> with it. Is there a rewrite rule that I can put into my httpd.conf  
> file  
> that will detect the incoming URLs with oldcompany hostnames and  
> redirect them to a particular HTML page?  
> For some time, I can keep both the new and old DNS names pointed to  
> the  
> same IP address.

From [URL Rewriting for Beginners | Alone On A Hill](http://www.addedbytes.com/apache/url-rewriting-for-beginners/)

To redirect an old domain to a new domain:

RewriteCond %{HTTP\_HOST} old\_domain.com [NC]  
RewriteRule ^(.\*)$ http://www.new\_domain.com/$1 [L,R=301]

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [October 7, 2008, 4:53pm UTC](https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340/3 "2008-10-07T16:53:51Z")

</div>

As always, thanks Peter.  
Regards,  
Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [October 8, 2008, 1:23am UTC](https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340/4 "2008-10-08T01:23:25Z")

</div>

Thanks Freddy,  
This was very helpful too.  
Regards,  
Bharat

---

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [October 7, 2008, 6:49pm UTC](https://www.ruby-forum.com/t/moving-from-one-dns-domain-to-another/150340/5 "2008-10-07T18:49:39Z")

</div>

Hi,

If you want the customer to land on a landing page that redirects  
after 5/10 seconds you should just setup two virtualhosts in apache  
one for the new domain and one for the old…

The old domain has one index.html file inside the doc root which has a  
META refresh inside. example:

 New Site Name The contents you are looking for have moved. You will be redirected to the new location automatically in 5 seconds. Please bookmark the correct page at www.newsite.com

That will give a landing page for the old site that redirects to the  
new site after 5 seconds…
