Saving Permalinks Doesn’t Update .htaccess File – WordPress Bug

Contents of the .htaccess file being empty

There is a bug in the current WordPress version (4.9.1) that prevents the .htaccess file from being updated properly when you save the permalinks. Evidently this bug existed in 4.9, but it is still a problem!

I noticed this over the last week or two. On multiple WordPress sites, when I’ve gone to update the permalink structure, every page returns a 404 not found error. Updating the permalinks is generally the solution to this problem, not the cause!

According to my website host, this is the bug report that tracks this particular problem. However, they claim to have fixed it but I’m still seeing the same problem.

Symptoms

  1. Saving the permalink structure (or, as I’ve been informed, sometimes simply logging in) causes all pages on a site to return a 404 page not found error.
  2. Upon investigation of the .htaccess file, you’ll see that only the #WordPress Start and #WordPress End lines are retained, with nothing between them.
  3. Deleting the .htaccess file and re-saving the structure results in a new .htaccess file with the same problem.

Solution to Permalinks Not Updating .htaccess File

For now, the main solution is to simply edit the .htaccess file manually. As far as I can tell, the only part that should be altered is the portion that allows WordPress to set custom permalinks for each page. This means that you can just add that one line in, and be all set.

Also note that the proper code is generally the same no matter which permalink structure you select within WordPress. This is because, again, the .htaccess code only allows WordPress to dictate the permalinks.

So, this is the code you want to make sure your .htaccess file has:

Obviously if you have custom redirects or commands in your .htaccess, you’ll want to retain those. In fact, you may want to make sure you backup your .htaccess file before doing anything with it.

I’ll update this page once the bug is fixed, but for now, be careful out there!

About Brian Johnson

Brian Johnson is a website developer and designer living in Minneapolis, Minnesota with a passion for code and WordPress. He spends his days building WordPress websites for small businesses, developing new code with the online community, and living life.

5 Comments on “Saving Permalinks Doesn’t Update .htaccess File – WordPress Bug”

  1. Hi, Brian could you pls help me out with permanlinks structure because whenever I tried to update the permalinks it shows “It’s updated” but in actual it’s not. I tried to edit the .htaccess file too and made sure that above code is in .htaccess file but till now the bug is there.

  2. Hi,

    any ideas why permalinks ending with a slash like /%postname%/ result in 404 errors because at some point this is translated to /%postname%/index.html?

    I do have the settings You mention in my .htaccess. The site runs if I choose /%postname% (omit trailing slash). But all settings with trailing slashes get malformed to ../index.html…

    I don’t get it. Any ideas?

  3. Could this mess up the SSL certificate too?
    My certificate is up to date, but all of a sudden today, it’s not installed properly. If I click to visit the site anyway I get a 404 page.
    The main page loads fine but all the others are messed up, I can’t even login and get to the back end. Sigh.

    My host deleted the ssl and now I’ve been waiting 6 hours for the new one to install.
    It seams to me there is something more wrong than that tho.

    1. Site appears to be working now! I assume you got it figured out? May have just been a problem with both. My guess is the SSL was deleted, you tried to fix the problem by saving the permalinks with meant you now have two problems!

Leave a Reply

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