Change domain name WordPress, the SEO friendly way

Change domain name WordPress, the SEO friendly way

How to change domain name of your WordPress site the SEO friendly way, without losing PR and link juice

I recently changed domain for this blog from egeek.dk to egeek.io. There are two parts of changing your domain or moving your site to a new host and domain – the technical part, and the SEO part where you try to preserve your search engine rankings. Doing it the right way will save you a lot less trouble in the future, and make you keep most of your hard earned SEO work. On the other hand, doing it wrong can have fatal consequences on your rankings in the search engines.

I’ll narrow it down and describe how I did it, and how you should do it too.

In my case I wanted to change domain from egeek.dk to egeek.io on a running WordPress site. I was not switching host/server, but just wanted to “rebrand” my site with a new domain. Whether you are in the same situation and want to rebrand your site, or want to switch host and domain, you can use these steps as a guideline.

I’m currently running this blog on IIS in a Windows Server environment, but the fundamentals are the same, and the following steps can be incorporated, should you run your site/blog on Apache, Nginx or on a LiteSpeed server in a *nix environment.

Disclaimer

Before starting out, I want to stress that changing your domain from olddomain.com to newdomain.com will affect your search engine rankings in the beginning. After you do a switch Google will index both of your sites, where after olddomain.com will slowly dissapear from the search results. I’ve had pages indexed with meta titles and descriptions chosen by Google, instead of the meta-data I chose for the pages (yeah, Google can do that). After the switch these pages are currently indexed with my new domain, and yet again Google has chosen meta titles and descriptions, though different (and much worse) than before. I had top 1 placements in Google with feature images and snippets, which are now gone after I changed domain. It’s a part of the process, but I’m positive the rankings and feature snippets will come back up, when everything is rolled out completely. It’s inevitable for things like these not to happen, as Google needs to reindex your whole site again. Don’t put too much concern into this though, as things will smooth out, and if you play it right, you’ll be back up where you were before. That’s what this guide is about.

Table of content

1. Domain name
2. Site and bindings
3. Change WordPress address
4. 301 redirects
5. Rename SQL database
6. Add properties in Google Search Console
7. Change address in Google Search Console
8. Submit sitemaps in Google Search Console
9. Update Google Analytics account and tracking code
10. Fetch site and submit to index
11. The afterwork

Read More

Redirect file to URL IIS

With this rewrite rule in your web.config, it’s possible to redirect a user from a specific file to an internal or external URL.
When they enter http://domain.com/folder/filename.html, they will be redirected to http://www.google.com

Note that this requires you have URL Rewrite installed on your IIS.

Place the following rule inside:
[xml]
<system.webServer>
<rewrite>
<rules>

Your rule goes here…

</rule>
</rules>
</rewrite>
</system.webServer>
[/xml]

Rewrite rule:
[xml]
<rule name="Redirect file to external url" stopProcessing="true">
<match url="^~/folder/filename\.html$" />
<conditions>
<add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
</conditions>
<action type="Redirect" url="http://www.google.com" appendQueryString="false" redirectType="Permanent" />
</rule>
[/xml]

IP restrict Azure website

As for now, it’s not possible to IP/Domain restrict an Windows Azure website from the administration portal. You’ll have to add security rules yourself to web.config associated with your website.

Go to system.webServer section of your web.config and add a security element, if you don’t already have it.
Inside you can configure security rules; “ipsecurity”.
Add the IP address and subnet mask for those IP addresses you want to allow access to your website.
If you need to allow several IP’s, simply duplicate the “ipsecurity” element and edit the IP address.

[xml]
<system.webServer>
<security>
<ipsecurity allowUnlisted="false" denyAction="NotFound">
<add allowed="true" ipAddress="8.8.8.8" subnetMask="255.255.255.0"></add>
</ipsecurity>
</security>
</system>
[/xml]

Gist: https://git.io/vrrEQ/a>

Redirect www to non-www IIS

This guide shows you how to redirect your site from www to non-www on server level with IIS 7.5.

www is actually a subdomain for your main domain (domain.com), which means both www.domain.com and domain.com will serve the same content, if you don’t redirect either www.domain.com to domain.com or the opposite way around. It’s highly recommended to do so, to prevent duplicate content. Which you prefer is entirely up to you, as it doesn’t matter in search engine rankings, as long as you choose one.

Fire up Internet Information Services (IIS) Manager by hitting CTRL+R and type inetmgr [enter]

Choose your site in the left menu and open up “Url Rewrite

Redirect www to non-www IIS

Click “Add rule(s)…”

Choose “Blank rule” under Inbound rules and click [ok]

Redirect www to non-www IIS

Give your rule a name, eg.: Redirect to non-www
Request URL: Match the Pattern
Pattern: (.*)

Open up the “Conditions” tab

Redirect www to non-www IIS

Condition input: {HTTP_HOST}
Check if input string: Does Not Match the Pattern
Pattern: ^domain\.com$ 

Redirect www to non-www IIS

Scroll down to the “Action” tab

Action type: Redirect
Redirect URL: http://domain.com/{R:1}
Make sure Redirect type is set to “Permanent (301)

Redirect www to non-www IIS

Done!

Another option, is to add the rule in your web.config manually:

[xml]
<rewrite>
<rules>
<rule name="Redirect to non-www" stopProcessing="true">
<match url="(.*)" negate="false"></match>
<action type="Redirect" url="http://domain.com/{R:1}"></action>
<conditions>
<add input="{HTTP_HOST}" pattern="^domain\.com$" negate="true"></add>
</conditions>
</rule>
</rules>
</rewrite>
[/xml]