What happens when permalink settings are updated?

I have two identical copies of the same site on two different webhosting companies (besides the actual domain of course). One of them works all the time with pretty permalinks and the other works fine a day or so, but then all of a sudden it does not work and the permalink gives a 404 file not found, but only when viewing a singe custom post page, named single-<cpt-name>.php in the theme folder.

When I go into admin / Permalink page – the site starts to work again (with the custom post page showing again)

My thoughts are that this must be server-related. The site that is working all the time has PHP 5.4 and the one that is not working all of the time has PHP 5.5, but I don’t think the version of PHP is the issue. Both sites have WP 3.8.

I’m using a cacheplugin called WP Supercache, but that doesn’t seem to be the issue because the site works again with cpt without flushing the cache (after viewing permalinksettings in admin)

I’m using permalink-structure: /%postname%/

I’m wondering how I could debug this? In order for me to debug this I want to know what happens (programmatically) when permalink-settings are updated? I think that the .htaccess in the root-folder (same as wp_config.php) is changed. (based on some reading) Is this correct?

I’m wondering if some plugin can cause the issue? (a plugin that somehow messes up pretty permalinks somehow)

My .htaccess looks like this (when working):

# 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

2 Answers
2

You’re correct, when you update the permalinks, the htaccess file also updates.

When you create or update a “pretty” permalink structure, WordPress
will generate rewrite rules and attempt to insert them into the proper
.htaccess file. If it can’t, it will say something like “You should
update your .htaccess now” and print out the rules for you to copy and
paste into the file (put them at the end).

Source: WordPress Codex.

First, verify that the htaccess file has the appropriate lines. Then verify that your hosting server has all the requirements (apache, mod_rewrite etc). Finally, disable all plugins and see if it works like that. If it works, enable one plugin at a time to find the one that’s causing the issue.

Leave a Comment