Case Study: 404 Errors When You Change Your Permalinks

Get A No Obligation Quote

Do You Need Help With Your WooCommerce Store?

Click through to the next page and complete the form to get a free no obligation quote to fix any issue you are having with your WooCommerce store.

Date

I have had a number of clients come to me with this problem, so I thought a case study was…

I have had a number of clients come to me with this problem, so I thought a case study was in order.

Here’s the Problem

When you change the permalinks from the default to something more pretty and SEO friendly, you click on a post or page link and all you get is a 404 file not found error. This is done from the settings-> permalink page.

The home page will be fine, but you cannot access any of your content off of the home page.

What Is A Permalink

A permalink is the URL of your blog post or page, the bit after your domain name for example the permalink of this post is case-study-errors-when-change-your-permalinks.

By default the permalink for a post or page is set to the post ID, so if I was using default permalinks, this post would look like this wpdude.com/?p=5770

What Having Pretty Permalinks Matters

It is a good idea to change your permalinks from the default to a pretty permalink (pretty is the technical term BTW, don’t believe me check out http://codex.wordpress.org/Using_Permalinks) for SEO purposes.

You can stuff valid keywords into the permalinks of your post to help the search engines match your content with searchers.

So What Has Happened?

When you change from the default to pretty permalinks WordPress needs to setup a redirect to the new URL, it does this by adding some commands to the file .htacess.   This file lives in the root of your site.

What Might Cause the Problem?

There are a couple of reason why this might not work, the first is that mod_rewrite is not installed on your hosting,  Check with them to see if they have this redirection technology in place.  I have not seen many hosting setups where this is not in place so you can probably move onto the next point.

Another reason I have seen 404 problems is when the .htaccess cannot be written to.  This might be file permissions or the file does not exist and WordPress cannot create it.

The Fix

Connect to your site using ftp and open up the .htaccess file.  NOTE some ftp client do not show hidden files by default so you may need to enable this. anything starting with a period/full stop is marked as hidden.

Edit the .htaccess file and see if it contains the following set of commands:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

If they are not present, you probably are having problems writing to the .htaccess file you can either change the permissions of .htaccess and try to regenerate the permalinks (you do this by setting it back to default, then setting it to pretty permalinks again) or you can manually edit and add the commands.

Please note if you are running WordPress in a subdirectory, you will need to reflect this in the command you add to the .htaccess file. Upload the file again and the 404 errors should be gone.

Wrap Up

So if you get 404 file not found errors when you change your permalinks, you need to manually edit your .htaccess file, if that doesn’t work check mod_rewrite with your hosting company, you can always roll back to the default permalink structure until you get this fixed to get your site back online

Image by everdred

6 thoughts on “Case Study: 404 Errors When You Change Your Permalinks”

  1. Oops, hope I don’t post this twice, anyway thanks Neil, very informative and I hope to try this out very soon!

  2. I pasted the code in and got a 500 error. If I put this code in, do I have to make the changes immediately to the permalinks or can I stay on the ugly ones for a while?
    Thanks for the info!
    Harv

    1. Harv

      If you get a 500 error that suggests that the mod_rewrite is not working correctly, check with your hosting company

      1. The Follow Up
        I learned a couple of things from this adventure. There is an order to how things need to happen and yes, your site will be messed up for a minute or two.
        1) Change .htaccess first
        2) make the change to the permalinks

        If you do it the other way, it just doesn’t work properly.
        Don’t panic if it doesn’t. As Neil mentioned, you can go back to the ugly permalinks and you haven’t lost anything. Then, re-group and do it right

        Good luck.
        I’m thrilled with the results
        Harv

  3. This was completely confusing. I couldn’t figure out how to even get into FTP file of site. I downloaded 3rd party ftp software. It said I was connected but, it still never showed me how to access file you were talking about. What is and where is htaccess file?

Comments are closed.

Get A No Obligation Quote

Do You Need Help With Your WooCommerce Store?

Click through to the next page and complete the form to get a free no obligation quote to fix any issue you are having with your WooCommerce store.

More
articles

Free Site Review

Book a no obligation WooCommerce optimization site review today.

Learn how you can increase sales from your WooCommerce store with a Free optimizatation review

Limited-time offer