I’m setting up a Wordpress website with a new domain name to replace my client’s current website. I’d like to redirect the old domain to the new domain in a way that will maintain the search engine rankings of the old site if at all possible. Once the new site is ready, my plan is to have the old domain name moved to a parked domain on the new server, and then use 301 redirects to redirect requests for the old domain name and html pages to the corresponding Wordpress pages on the new domain. So, as an example, a request for http://www.olddomain.ca/success-stories.html would be redirected to https://newdomain.com/testimonials/.
I’ve tested the redirects for each html page on the new server and it seems to work correctly, but I’m not sure how to test redirection of the old domain name until it’s actually set up as a parked domain pointing to the new server.
So I have two questions:
- Will this approach maintain the search engine ranking of the old site, or is there a better way?
Will these rules redirect the parked domain to the new domain (in addition to removing www)?
RewriteCond %{HTTP_HOST} !^newdomain\.com [NC] RewriteRule ^(.*)$ https://newdomain.com/$1 [R,L]
I’m using 302 redirects for now, but will switch to 301's once I’m done testing. This is my first time working with the htaccess file, so I welcome any other suggestions on how to improve it.
# Redirect HTML pages from old site to new equivalents
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html?$ / [NC,R,L]
RewriteRule ^about-us\.html?$ /about/ [NC,R,L]
RewriteRule ^coaching\.html?$ /services/ [NC,R,L]
RewriteRule ^how-we-do-it\.html?$ /services/ [NC,R,L]
RewriteRule ^news-calendar\.html?$ / [NC,R,L]
RewriteRule ^philosophy\.html?$ /about/ [NC,R,L]
RewriteRule ^services\.html?$ /services/ [NC,R,L]
RewriteRule ^success-stories\.html?$ /testimonials/ [NC,R,L]
RewriteRule ^teams\.html?$ /services/ [NC,R,L]
RewriteRule ^training\.html?$ /services/ [NC,R,L]
# Remove WWW Prefix, enforce HTTPS, and redirect parked domain
RewriteEngine On
RewriteCond %{SERVER_PORT} 80 [OR]
RewriteCond %{HTTP_HOST} !^newdomain\.com [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [R,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress