Changing Bitnami WordPress permalink structure without causing 404s and maintaining SEO

I’ve been recently tinkering with the idea of using Ghost, another content management system (CMS), to manage the blog posts and back end stuff of my blog here since I find Ghost can be rather more streamlined and less.. “bloated” than WordPress can be at times. Having tinkered with Ghost in a container in Azure Container Instances, my initial plan was put on pause as I found that the overall cost to running a container in the cloud was just too cost prohibitive (almost 10x what I currently pay) at this time, more on that in another blog post I think.

What I liked about my brief test of Ghost was that not only does it have great features comparable to WordPress, but out of the box the post format was something like:

I checked my blog to see the format as it’s not something I really think about. Low and behold I’m using a similar format that’s not quiet WordPress out of the box , but is rather close to this new target state idea that I’d like to resemble Ghost. For reference, WordPress out of the box has a format that resembles:

That’s certainly not very Search Engine Optimisation (SEO) friendly. So very early on I changed that formatting to be 1) more SEO friendly and more importantly 2) user friendly. At the time I had a theme with specific archive pages for year, month and day of posts. With that I had the grandiose plan of writing very often and I thought that certainly readers would appreciate that level of searchability.

Fast forward to several theme revisions later and that level of search is now defunct. So I wondered if it would be easy enough to change the permalinks formatting now on the blog without breaking any links and SEO. I don’t expect much from SEO and while it certainly helps to get exposure, I didn’t want to just lose any of the momentum that the blog has gotten over the last 4 years.

My blog is hosted on AWS Lightsail and runs Bitnami WordPress instead of the official WordPress deployment. Bitnami WordPress is a customised instance of WordPress where Bitnami add in a number of improvements to the out of the box WordPress experience. I’m all for improvements. I do find that the Bitnami documentation is pretty comprehensive and I appreciate the effort in that doco. My problem is that there isn’t much specific detail on 301 redirects and there’s also a number of Bitnami WordPress images with slight tweaks for different cloud providers. With other bloggers out there documenting their own experiences, mine was not that straight forward; hence this blog post.

So thinking this through, the solution should go something like the following:

Hold on there slick.

As I said before, this was harder than I thought. Not impossible by any stretch of the imagination. It just needed some thorough research as the overwhelming majority of useful information just referenced the most common recommended approach of putting in redirects in the Apache web server .htaccess file. That’s just a configuration file that allows 301 redirects to happen (among a bunch of other good stuff) at the server level.

Now I could look to do this in Cloudflare as I use their excellent service (love their work! Before you ask: no, this isn’t a paid endorsement). So rather than the request ever hitting my server, the redirect could happen at the edge. Thus reducing my cloud cost. More edge = less cloud cost. My wallet and I both love that. I didn’t want to explore that option as I think the .htacess approach is faster.

After spending quite a bit of time reading not only Bitnami knowledge base articles, to WordPress knowledge base articles, to blog posts to even YouTube videos on the topic, I managed to collate a few sources together into a final solution. What was the key final find was on the yoast.com website which provide SEO plugins and services for WordPress. I use the plugin, very, very lightly and really if I lost it tomorrow, it wouldn’t make much of an impact to the blog. So with that, I didn’t want to fork out for a subscription for the service.

Digging deeper and I eventually stumbled upon a blog post that Yoast put out there about this requirement. When searching around that topic I then got to a helper service that Yoast has freely on their website for the exact redirect I wanted to do! Progress! Bellow I go into how to use that helper, so I’ll leave that there. Now, the only other thing to get this working was this .htaccess file.

Bitnami WordPress moves the functionality of the .htacess file to a new folder in its file structure and into a file altogether called htaccess.conf. This was part two of the harder than I thought problem solving here. There’s a bunch of mixed information out there that references this file (the htacess.conf). Additionally there’s a few another key files that come up quite often in Google, like httpd.conf, httpd.app.conf and httpd-vhosts.conf. I’m not that experienced with Bitnami Wordress or Apache to know if these other config file amending solutions are correct or not. They may well offer the same solution.

After playing around early one morning over the last week and effectively breaking traffic getting to to the blog, I eventually got the solution below using the htacess.conf file. I just wanted to outline that as surely there’s more than one way to skin a cat. This is the way it worked and continues to work for me.

The solution walk through

cd opt/bitnami/apps/WordPress/conf sudo nano htaccess.conf

sudo /opt/bitnami/ctlscript.sh restart apache

Enjoy!


Questions?

Have a question about this post? Ask away on Twitter or in my AMA repo.