Move To A New CMS And Keep All Links Intact

Armin Baldemair
armix.one
Published in
3 min readSep 5, 2016

--

About one week ago I decided to move my blog from my own WordPress installation to Medium. My blog exists since over ten years and over the years I used many different URLs: blog.armix.net, www.armixblog.com, a0.io, armix.net, blog.armix.one … and finally armix.one.

There are still some links to the old URLs and not all content management systems use the same link/URI structure.
For example: To list all posts with a given tag you can use /tag/tagname, if you use WordPress as your Content Management System (CMS). Medium uses /tagged/tagname. It’s very cool that Medium understands the WordPress URIs if you have a Medium publication with a custom domain — Medium translates URIs with /tag/ automatically to /tagged/. This solves the path problem.

But there is still the problem with the different domains. Until last week I simply pointed all my blog domains to the IP address of the Amazon EC2 instance with the WordPress installation. The primary domain was armix.one; blog.armix.net, a0.io and the other (old) domains pointed to the same IP address and the Apache HTTPD on the EC2 instance did the rest.
With Medium you can use only one domain per publication. So what to do with all the other domains? Redirect them!

This is where the DNS services comes into play. I use CloudFlare for most of my domains. CloudFlare is the best DNS service I know — and they offer a free service plan, which is absolutely sufficient for most cases! CloudFlare does not only the name resolution thingy. The service also includes caching, SSL/TLS-encryption and many other really cool features. One of this features is called Page Rules.

With Page Rules you can easily redirect any URI to any other URI. Many DNS services offer simple domain redirection, but Page Rules are more powerful: They allow wildcards (*) and you can also use variables ($).

CloudFlare Page Rule: URL Forwarding (HTTP 301 Redirect)

The example above redirects all requests from blog.armix.one (http and https) to the primary domain armix.one. The value of each wildcard can be used with the corresponding $ variables. This means that $1 would include the schema (http:// or https://) and the value of $2 equals the path after the domain name — e.g. /tag/azure.

Let’s assume you found a link to a blog post about Microsoft Azure and this post was created when I used the domain blog.armix.one. The URI of the post would be http://blog.armix.one/tag/azure/ . When you click on the link the following happens:

  1. Your request is sent to a CloudFlare server.
  2. CloudFlare detects that there is a corresponding Page Rule defined.
  3. CloudFlare replaces the schema http: with https: and the domain name blog.armix.one with armix.one.
  4. Your browser receives a HTTP 301 redirect to https://armix.one/tag/azure.
  5. This redirect request is sent to Medium.
  6. Medium detects that the URI includes WordPress-style tags and replaces /tag/ with /tagged/.
  7. In this case the final URI is https://armix.one/tagged/azure.

This works great and ensures that all your links remain intact.

--

--