htaccess file

I am moving domains.  On the old domain I created an htaccess file with the following contents only:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule (.*)$ http://www.new.com/$1 [R=301,L]

Is this correct?  Should I have any other code or text int he file?
a204801Asked:
Who is Participating?
 
InsoftserviceCommented:
Its correct you could even try this one

RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
0
 
a204801Author Commented:
Im trying to preserve the existing link structure.  So if they go to

old.com/why/because

they end up on

new.com/why/because

Not to mention, if they go to www.old.com or old.com, they get forwarded to www.new.com
0
 
InsoftserviceCommented:
what you want actually .
As your htacces says that it has to redirect to new one
please elaborate your reuirement
0
 
a204801Author Commented:
I believe I figured out the issue.  I had the DNS host pointing towards the correct spot, but I didn't realize that www, via CNAME, was still pointing towards the old host.  I have rectified the mistake.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.