4

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
1
  • @Oliviadavid Why do you think that?
    – MrWhite
    Commented Nov 23, 2017 at 16:00

2 Answers 2

4

1) By applying 301 redirects you will basically tell search engines that you have moved that page or group of pages to another location permanently. No problems here, all good.

Google has declared several times that 301 won’t have an impact in transferring the ranking power from those links pointing to your old URLs. So to answer your first question, rest assured you won’t loose any rankings that way.

However, you might loose ranking from potentially more than 200 other ranking factors that will have to be reassessed once you have the new website live. You might loose rankings for changing the layout, website structure and design, having new content, etc. You might also loose ranking even by changing servers, the website will have a different location to serve content from, impact in performance will also be playing an important part.

What is expected before someone decides to migrate, upgrade or improve any website, is that we know our customers needs or we have learned from our past experiences enough that any chance we do will have a positive impact in the business or most importantly to our user base. But unfortunately that is not always the case.

2) the htaccess code looks good, but don’t take my word, you need to test it because each environment is different. Make sure that when you are trying to redirect any URL, specially the homepage, you don’t do more than one redirect.

So for example, if you are redirecting example-old.com to example-new.com make sure you don’t redirect first to www.example-old.com and then to example-new.com.

Make tests so you can be sure that either www. Or non www. version of the website will redirect always to example-new.com

1
  • Great feedback, thank you. I have tested all the scenarios and combinations I can think of so far (www to non-www, http to https, and html to wordpress pages) - everything except for the old domain to the new domain. I'll keep testing to make sure it's not doing more than one redirect. I'm not sure if there's much I can do to minimize the impact of changing structure/content. We've put a lot of thought into how to improve the layout and the content.
    – Tom Monks
    Commented Nov 23, 2017 at 12:44
2

Comment: I'll keep testing to make sure it's not doing more than one redirect.

The directives you posted would trigger multiple redirects if requesting the old domain.

# 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]
:

Unless you include the new domain in the substitution, then you are going to redirect /about-us.html to /about/ on the old domain before being redirected to new-domain.com/about/ (by your catch-all redirect).

So, your redirects should be of the form:

RewriteRule ^index\.html?$ https://newdomain.com/ [NC,R,L]
RewriteRule ^about-us\.html?$ https://newdomain.com/about/ [NC,R,L]
:

(Unless you removed the L flag from these directives so they are passed through and were caught by the catch-all redirect that follows - however, that would be less reliable and more prone to error.)

RewriteCond %{HTTP_HOST} !^newdomain\.com [NC]

You should remove the NC flag from this negated condition. You want the redirect to occur when the Host is not "newdomain.com" (all lowercase). You want to still redirect "NEWDOMAIN.COM" (a malformed request). If you include the NC flag then "NEWDOMAIN.COM" would not be redirected since the condition would fail.

RewriteEngine On
RewriteBase /

Aside: You only need to include these directives once in the file (in fact, you don't appear to be using RewriteBase at all in the code you have posted). If you include these directives more than once then the last directive wins and controls the entire file.

1
  • 1
    Wow, these are great tips, and very well explained. Thanks a lot. I will make these corrections.
    – Tom Monks
    Commented Nov 24, 2017 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.