301 Redirection and SEO Blog Engine to Ghost
After the successful migration of content I needed to put in place 301 Redirects to move visitors from old blog to new. This needed .htaccess file changes, and jumping through hoops for Google.
For reasons I'll describe, the final part of moving from Blog Engine to Ghost was a marathon. But it's done now! (Yaaaaay!)
After the successful migration of content I needed to put in place 301 Redirects to move visitors from the-north.com/sharepoint to this blog instead. This helps people find the content in the new blog, and the 301 keeps your search rankings sweet. There were a couple of challenges there;
First I was moving from a folder (sharepoint) to the root of jamiemcallister.com and second Blog Engine puts material in the Post folder, also not present on Ghost. Since Blog Engine is an ASP.Net based App and I used to develop that for a living I'm happy to say that went pretty well. Best solution in the end was to modify the web.config file with a rewrite rule;
<rules>
<rule name="redirect" enabled="true">
<match url="^post/(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www.the-north.com/sharepoint/post/$" />
</conditions>
<action type="Redirect" url="https://jamiemcallister.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="redirectFolder" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" negate="true" pattern="^www.the-north.com/sharepoint/$" />
</conditions>
<action type="Redirect" url="https://jamiemcallister.com/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
The above is coping with the pages in the 'post' folder and visiting the 'SharePoint' folder in general.
This mostly solved my problem, but I still had to redirect my root site the-north.com and that wasn't an ASP.NET application. It was clear that I needed to add a .htaccess file to that root to do a 301 redirect.
The contents of my .htaccess file were this (which wasn't a full solution as you'll see later);
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.the-north.com
RewriteRule (.*) https://jamiemcallister.com/ [R=301,L]
So I'm telling it to do a re-write, matching my domain, and sending the content to jamiemcallister.com. The square brackets are telling it to return a 301 i.e. notification of permanent redirect, and L means if this rule matches treat this as the last one - stop execution. (I know there's no other rules in the file but it's neat innit?!)
The redirects seemed to be working fine for the root and the Blog Engine bit. So the next stage was to go to Google Webmaster tools and inform it that a change of address was needed. This aids your SEO (Search Engine Optimization) in that results that Google might have directed to your old domain will get sent to the new one.
You need to have established owneership of the domains to Googles satisfaction already, then you choose the domain in the Webmaster Tools page, click the cog, and select "Change of Address". I did that, and got the below;
"we couldn't find any 301-redirect directives for your site. for more details check the fetch as google tool"
This was a real head scratcher for a while. I thought maybe my web.config changes were wrong. Used Fiddler to ping the various pages and the root and they were all giving a 301 Redirect as they should. Finally using the 'Fetch as Google' tool I realised that www.the-north.com and http://www.the-north.com was giving different results. The first redirected and the second didn't. So I went back to the .htaccess file and came up with this;
RewriteEngine on
RewriteCond %{HTTP_HOST} !^http://www.the-north.com
RewriteRule (.) https://jamiemcallister.com/ [R=301,L]
RewriteCond %{HTTP_HOST} !^www.the-north.com
RewriteRule (.) https://jamiemcallister.com/ [R=301,L]
This finally fixed my 301 issues, and I got a green tick in Google, but my victory was short lived;
the-north.com had been verified with Google for years. You do this by either adding Analytics code to the page HEAD, other verification codes to HEAD, upload a HTML file of a specific name to root, use Google Tag Manager (add code to every page), or amend your TXT file at your domain host.
Puzzled I tried re-uploading a verification file and made me realize what was happening;
The 301 redirection meant the file wasn't considered to be in the-north.com anymore but in the new domain!
Just for laughs, I've highlighted every verification method that breaks when you redirect the site elsewhere. Google can't find the codes because of the redirect, which they've just insisted you do in the prior step!!!
Turning off redirection doesn't work either because it checks everything again when you click submit and spots the change;
Checking my domain host it wasn't possible to add a TXT record to my zone file, and none of the other verification steps were working. I banged my head on the monitor a few times, and as the stars swirled around my head I realised I could use the HTML File Upload method, but exclude that file specifically from redirects in my .htaccess file. (Was this obvious to you from the start? Sorry you didn't blog it then you'd have saved me loads of time :D )
The final working version of my .htaccess file then became;
RewriteEngine on
RewriteRule google1aeea49788a77e50.html - [L]
RewriteCond %{HTTP_HOST} !^http://www.the-north.com
RewriteRule (.) https://jamiemcallister.com/ [R=301,L]
RewriteCond %{HTTP_HOST} !^www.the-north.com
RewriteRule (.) https://jamiemcallister.com/ [R=301,L]
Finally Google gifted me with the winners screen. Blog migration complete;
Despite all this I also discovered using the Google tools that there are thousands of inward bound links to the-north.com from other peoples Blogs and forum posts referencing my articles. Alas when the-north.com is fully retired I'll lose that traffic. :(
Moving domains, so much to think about when you get into it. Hope this helps somebody! :)