in Wordpress

Changing Permalinks On WordPress

Insert Link

Today I've have committed blogging and Wordpress sin! I have changed the permalinks on my blog. But I have done it in complete confidence that it will not 404 any of my pages, will not affect my search engine results and will increase average time spent on my blog. In this article I will explain how you can do exactly the same thing if you feel like you have made the wrong choice on permalinks.

Permalinks are the structure that your URLs are displayed. As wordpress default they are not very user friendly or SEO friendly your first post on your site will be This gives your visitors no idea what this post is about and will affect your SEO. Permalinks is one of the first things you have to decide what to do with after you have installed Wordpress. For a full guide of what to do after installing Wordpress have a look at my guest post at You need to decide what structure you are going to be using as it is important on how your blog is viewed.

I made a mistake choosing the permalinks for my website, I choose to have the date in the URL of my posts. The URLs used to be Since using this I realised that for the type of posts I publish ie. tutorials, snippets and knowledge I realised that this type of URL could actually be negative to my site. Even if the content I publish can be used for years to come who wants to read a post from last year, if your searching for how CSS animation works I would much rather read something written yesterday than last year even if the content is very similar. I would trust the newer content more, I would think it's more up to date so it must be right. For my tutorials if someone can see that the post was done a couple of months ago this might mean that they won't even click through to read the content. This is a big problem and could be costing visitors to my site, something I must fix now.

I decided to remove the date from my permalinks. The new structure will now be Clean, simple, straight to the point. Perfect just what I want. Changing the URL structure of a already existing website can be a challenging process. Now already indexed pages will redirect to your old URL and the page won't be there anymore causing a 404 on all your pages. You have built up an index in the search engines and now you are going to take that away by changing your permalinks. To get around this problem you need to make some changes to your .htaccess file. You need to redirect all the old URLs to the new structure. Not too difficult all I need to do is search to see if there is a date in the URL, if there is then remove it and 301 redirect to the new URL. 301 redirect is a permanent redirect which will tell the search engines that this has been moved to this new URL so transfer your index and any page rank to this new URL. Now go to your Wordpress dashboard and go to: Settings > Permalinks Permalinks

As you can see my custom URL is /%year%/%month%/%postname% now remove the /%year%/%month%/ from the URL and we are left with the postname. Click save changes button and Wordpress will change all the URLs on your blog. Go to your home page and click on a post you will see the URL has changed to the new format. Now go to a search engine and find one of your posts and click the link to your post. You will see it now goes to your 404 page, you will need to change your .htaccess file to 301 redirect to the new URL.

Flush Rewrite Rules

When you change your Wordpress URL structure then the Wordpress database will need to be updated with the new URL structure rules so it will understand how to search for your posts from the given URL. Sometimes you get the problem of changing a URL structure and Wordpress returning a 404 page for all your posts. This can be because the rewrite rules have not refreshed correctly. First you can navigate to the permalinks page Settings -> Permalinks and change the permalink click the save button, then change it back to the way it was. This will refresh all the rewrite rules on your website and your custom post types should be displayed. Secondly you can open phpMyAdmin, navigate to the wp_options table and delete the rewrite rules record from this table. Next time WordPress loads it will check for the rewrite rules in this table if they aren't there then it will regenerate the rules. The third option is to place the function flush_rewrite_rules() under the register post type function. This will completely refresh the post type rules and fix any problems with redirecting.


Changing The .htaccess

Open up your .htaccess file and find where Wordpress already does a redirect on your site. The code will be inside the comments

# BEGIN WordPress

Find where it says RewriteEngine On and directly under this line you will enter your change. For my example I am searching for URLs with year and month in them and removing them from the URL so I used the following line.

RedirectMatch 301 ^/[0-9]{4}/[0-9]{2}/([a-z0-9-/]+)$1

Save the .htaccess file and upload to your server. Now go back to a search engine find one of your posts click through when your post loads up you will see that your post is now using your new URL structure.

Easy Way Of Finding Your Posts In Google

If you can't find your posts in the search engines use this tip. Type in your domain name prefixed with site:.

It will return will pages that are indexed on this domain.