skip to Main Content
  • SEO
WordPress Permalink Structure Change

The best WordPress permalink structure SEO wise has been debated a lot over the last couple of years. And with good reason. SEO or the “findability” of your website matters. The best permalink or url structure for WordPress posts according to many bloggers and WordPress authorities is either:

%postname

or

/%category%/%postname%/

Most or proponents of the %postname% one. Often it is the better option when your posts titles are rather long. And or when your post titles and so post slugs contain all the keywords including possible category labels. Let’s say you thought it all through and you need a WordPress Permalink Structure Change. This because you are using neither of the two mentioned structures, which is bad. Or because you realize – perhaps after reading this post you need to switch to %postname% or %category%%postname%.

Permalink Structure Change

So let’s say you want a WordPress Permalink Structure Change. You perhaps realized you were not using the correct permalink structure. You found out using %postname% is the best WordPress permalink structure for you. Well,  you can easily change that in settings > permalinks. Vice versa as well of course. But we will move to %postname% further down this article.

Redirect Issues

You will need to think about your SEO and people and search bots possibly getting lost finding existing articles. This because visitors bookmarked the posts using the old structure. Or because bots cached the old locations. For that Yoast SEO has a neat little tool. This tool generates the .htaccess redirect needed. Once that is done you just need to download the .htaccess, add the redirect line at the top and upload the adjusted file. Another choice is a redirect plugin. See remarks later on!

%Category%%Postname% to %Postname

I decided just recently to move to %postname% from /%category%/%postname%/as I realized my blog posts often had the category in the name too, often duplicating the category label in the blog post title. So I changed to it under permalink settings.

Yoast Redirect – Too General in Approach

To deal with the redirect issues initially I used Yoast’s redirect generator tool to get the proper .htaccess redirect. The one generated was:

RedirectMatch 301 ^/([^/]+)/([^/]+)/$ https://imwz.io/$2

If you are good at Apache and Apache configuration and regular expressions you could have solved this yourselves. Me, I am not too bad at working with .htaccess, but why not use a ready made tool when there is one available right? Well..

Issues

I realized though that categories used will be ignored from this moment on using this redirect. The redirect is too vast, too general. So if you did use them as menu items or otherwise it would be wise to remove them. Two, If you would like to continue using tags do not use the above mentioned redirect. These will also no longer work

Simple 301s Redirect Plugin – Best Choice for Redirect Fixes

In the end I used the Simple 301s Redirect Plugin to only redirect urls to posts still containing the category to the url without the category. This allows you to also indicate you go from permalink type x to y like %category%%postname% to %postname% :

Simple 301s Redirect Plugin

NGINX Permalink Change

For NGINX I recommend using Trellis to deal with it all on the fly. But otherwise a setup including:

location / {
    try_files   $uri $uri/ /index.php?$args;
}

should deal with the changes. Basically it tells users that hit a 404 due to changes to go to the index. Once they are there WordPress is smart enough to deal with the request. See Stack Overflow on it here. It includes a full configuration file too.

 

Jasper Frumau

Jasper has been working with web frameworks and applications such as Laravel, Magento and his favorite CMS WordPress including Roots Trellis and Sage for more than a decade. He helps customers with web design and online marketing. Services provided are web design, ecommerce, SEO, content marketing. When Jasper is not coding, marketing a website, reading about the web or dreaming the internet of things he plays with his son, travels or run a few blocks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top