/ Web Design

How To Redirect Old Ghost Blog Content To A New Blog On A Nginx Server

Previously this blog was hosted at https://www.murwell.com. I recently wanted to bring this blog in line with other domains that are running (ie. - law.murwell.com, food.murwell.com, and so on) and make the domain address for the blog to be at blog.murwell.com.

The problem is that search engines like Google still refer traffic to the old website.

Screen shot from Google showing that web traffic is referred to www.murwell.com rather than blog.murwell.com

This means that any web traffic from those websites would find the dread "404 - Content Missing Page." And we all know what that means; they go somewhere else.

Now, the postings on the old Ghost Blog used the year of the post as the name of the first directory. For example - https://www.murwell.com/2016/ . . . So, basically I wanted web traffic that was going to this address to go to https://blog.murwell.com/2016 . . . instead.

To permanently redirect the traffic, I only needed to add a line of code in the old domain's (i.e. - www.murwell.com) configuration file in NGINX "sites-available" directory.

cd /etc/nginx/sites-available/

sudo vim your_configuration file (or use whatever text editor you prefer).

In the server block, I added the following:

rewrite ^/2016/(.*)$ https://blog.murwell.com/$1 redirect;

wq or however you save in your text editor.

sudo service nginx restart

And that's it. Now traffic to the old domain (https://www.murwell.com/2016/11/16/free-murwell-amp-html-template-2/) gets propely redirected.