Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Update WordPress permalinks easily without losing SEO

Update WordPress Permalinks Easily Without Losing SEO

These days SEO experts recommend that the permalinks for WordPress and ClassicPress websites are set to ‘post name’. If you have an older site then you may have chosen a different Permalink structure. Now you want to change it, but you’re worried about losing precious SEO indexing.

There are good reasons for choosing ‘post name’ for your permalink structure. It keeps URLs as short as possible while still conveying meaning and keeps URLs free from useless information. It also stops people being discouraged from clicking a search result if they see an old date in the URL.

But if you suddenly change your permalink structure, what happens to all those old URLs that have already been indexed by Google? Well, they will throw a 404 error. Not good. All that hard work wiped out in a stroke.

Note: if your old permalink setting was ‘Default’ or ‘Category – name’ then you don’t have to do anything at all – WordPress will handle the redirects automatically.

The hard way to update your permalinks without losing SEO

After changing your permalinks on the permalink settings page, you could install a redirection plugin (there are several good free ones) and manually add entries for all the posts that have been indexed by Google. So each redirect entry would be something like this:

FROM: https://www.zigpress.com/2018-04-15/this-is-the-post-title/
TO: https://www.zigpress.com/this-is-the-post-title/
TYPE: 301

This will work but if you have a lot of posts, this is a long, tedious, task.

The easy way to update your permalinks without losing SEO

If your web host is running Apache (in other words, if the .htaccess file is used on your site), there is a much easier way.

Step 1

Install and activate our free plugin ZigHtaccess which will let you edit the content of your .htaccess file. It’s compatible with both WordPress and ClassicPress. Here’s the link to the ZigHtaccess page in the WordPress plugin repository.

Step 2

Go and change your permalinks to ‘Post name‘ after making a note of what they were set to before (for example, ‘Day and name’ or ‘Numeric’).

Step 3

Use the ZigHtaccess editor page (reached from ‘Settings’) to add a line of code at the top of your .htaccess file. In each case below, replace www.mydomain.com with your actual domain name!

Please copy and paste carefully, since an .htaccess file with errors can break the front end of your site. And please ensure you add the line to the top of the .htaccess file, before any other lines in the file.

Note: if your site runs in a subfolder, scroll further down for the correct code.

If your old permalink setting was ‘Day and name‘, add this line of code to the top of your .htaccess file:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$ https://www.mydomain.com/$4

If your old permalink setting was ‘Month and name‘, add this line of code to the top of your .htaccess file:

RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://www.mydomain.com/$3

If your old permalink setting was ‘Numeric‘, add this line of code to the top of your .htaccess file:

RedirectMatch 301 ^/archives/(\d+)$ https://www.mydomain.com/?p=$1
If your site runs in a subfolder

If your WordPress site runs in a subfolder (for example www.mydomain.com/blog), you need to amend the code as shown below. In each case, change the word subfolder to your subfolder name.

If your old permalink setting was ‘Day and name‘, add this line of code to the top of your .htaccess file:

RedirectMatch 301 ^/subfolder/([0-9]{4})/([0-9]{2})/([0-9]{2})/(?!page/)(.+)$ https://www.mydomain.com/subfolder/$4

If your old permalink setting was ‘Month and name‘, add this line of code to the top of your .htaccess file:

RedirectMatch 301 ^/subfolder/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ https://www.mydomain.com/subfolder/$3

If your old permalink setting was ‘Numeric‘, add this line of code to the top of your .htaccess file:

RedirectMatch 301 ^/subfolder/archives/(\d+)$ https://www.mydomain.com/subfolder/?p=$1

Done

When you’ve added the correct line of code to your .htaccess file, save the changes and you’re done. Now test your site, and click some of your Google search results to make sure the redirect is happening. Once you’re happy that everything is OK, you can deactivate and even remove ZigHtaccess if you like – or you may decide it’s a useful plugin to have available. It’s up to you.

And in fact after a few months, once you’re sure that Google has caught up with your permalink changes, you can even use ZigHtaccess to remove the new line from your .htaccess file, since it will no longer strictly be needed.

If you need to reverse the process for any reason, simply remove the new line from your .htaccess file and save the changes, then go to the permalink settings page and switch the permalinks back to what they were before.

If you don’t feel confident doing this yourself, we’d be happy to help for a small fee – just use our Contact page to get in touch.

Disclaimer: This article and the ZigHtaccess plugin are offered without any kind of warranty, promise or guarantee, and the article and plugin author bears no responsibility for any problems or loss of code, data or income incurred as a result of using this article or the plugin.



This post first appeared on ZigPress, please read the originial post: here

Share the post

Update WordPress permalinks easily without losing SEO

×

Subscribe to Zigpress

Get updates delivered right to your inbox!

Thank you for your subscription

×