1

I have a domain called olddomain.com. Now I want to point the DNS entry to newdomain.com. Can I then use a .htaccess which determines if the user comes from olddomain.com and redirects to newdomain.com/path/welcomepage.html?

I found this and created something like

RewriteCond %{HTTP_HOST} ^http://www.olddomain.com/$ [NC]
RewriteRule ^path/welcomepage.html$ http://www.newdomain.com/$1 [R=301,L]

Would this work (together with pointing the A-record or CName-record on newdomain.com)?

The redirect should be permanent. So should I use R=permanent,QSA,L like here?

Edit:

Now I tried the lines from Seybsen together with the following CName record:

Typ: CName record
Name: www.olddomain.com.
TTL: 3600
Cname: newdomain.com.

But the result is (with and without the redirect) that only a advertisement from the provider of newdomain.com is shown.

Community
  • 1
  • 1
testing
  • 19,681
  • 50
  • 236
  • 417

1 Answers1

2

I would just do it like this:

RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/path/welcomepage.html [R=301,L]

means: when someone gets to your page via olddomain.com or www.olddomain.com he will be redirected to the newdomain's welcomepage.

EDIT:

If you have the possibility to set an A-Record for www.olddomain.com and olddomain.com I would set them both to newdomain's server IP.

A CNAME for the domain olddomain.com would be against DNS RFC so not advisable; you can only set it for www.olddomain.com what will require a redirect (for example with a .htaccess) from olddomain.com to www.olddomain.com which then points through CNAME to www.newdomain.com I'm assuming here that www.olddomain.com and olddomain.com should both show the welcomepage of newdomain.com

Community
  • 1
  • 1
Seybsen
  • 14,989
  • 4
  • 40
  • 73
  • Thanks for your answer! Could you also help me with the Cname record? Do I have to contact the provider or I'm doing something wrong? See my edited question. – testing Nov 04 '11 at 17:32
  • Try contacting the provider of newdomain. Your CNAME seems to be correct. – Seybsen Nov 04 '11 at 20:07
  • I contacted the provider from www.oldomain.com and www.newdomain.com. At both I had to set up a redirect (which only is available from the domain provider). I never could test it because I had problems and in the end the domain was canceled.... – testing Nov 15 '11 at 17:01