I am much more of a programmer than a server guru so any help is much appreciated!

Forwarding a domain name for SEO reasons ->
NewDomain.com hosted with 3rd party needs to point to currently hosted site CurrentDomain.com. I know I need to...

1) Adjust NewDomain.com DNS A records specifically

  • www.
  • @.
  • *.
  • ftp.
  • mail.

2) Adjust NewDomain.com DNS MX records

3) Add 301 Redirect to .htaccess file hosted at CurrentDomain.com so all requests for NewDomain will be forwarded to CurrentDomain.com.

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

THE QUESTIONS:
What else needs to be done?
1) Is something missing?
2) Should additional DNS changes be made? If so, where?
3) Should MX record point to mail.CurrentDomain.com if I don't want mail to NewDomain?
4) Is there a better .htaccess file?

有帮助吗?

解决方案

Your .htaccess is almost right, just minor corrections:

Options +FollowSymlinks -MultiViews
RewriteEngine on

# for http
RewriteCond %{HTTP_HOST} ^(www\.)?newdomain\.com$ [NC]
RewriteCond %{SERVER_PORT} =80
RewriteRule ^(.*)$ http://CurrentDomain.com/$1 [R=301,L]

# for https
RewriteCond %{HTTP_HOST} ^(www\.)?newdomain\.com$ [NC]
RewriteCond %{SERVER_PORT} =443
RewriteRule ^(.*)$ https://CurrentDomain.com/$1 [R=301,L]

That way newdomain.com or www.newdomain.com will both be redirected with 301 to the browsers.

[NC] flag is for ignore case matching of host

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top