WordPress Permalinks Not Staying

At various points of the day my WP permalinks keep breaking. When I’m using custom perms it works but then a few times during the day it just throws a Page Not Found. I fix it by setting perms to default, then back to custom and it works fine.

My Sys Admin can’t figure it out. Hopefully a guru can lend some help?

Related posts

Leave a Reply

9 comments

  1. The problem is indeed most-likely the sCategory Permalink plug-in (the one that gives you /%scategory%/. 404s are somewhat common. Go to Options | Permalinks page in Site Admin and click Save Changes to regenerate permalinks. They way to confirm this is to use WP-default permalinks to test behavior. If all is working well, it is the sCategory Permalink.

    If this isn’t working, publish your .htaccess and that will help us troubleshoot better.

  2. I’d be suspicious of something that is periodically overwriting your .htaccess file. When you set the permalink options, it updates .htaccess. If those settings are being “lost”, there might be another piece of software running on your site that is mucking with the .htaccess file and removing or overriding the WordPress settings.

  3. It seems that something else is automatically changing your htaccess file and overwriting the permalink settings.

    What bvandrunen suggested may work. If not, you could set the permalink settings to what you want and then immediately change the permissions of the htaccess file to prevent anything from modifying it. I would suggest using chmod 644.

    Naturally, a better solution still would be to find the script which is modding your htaccess file and get rid of it… but this fix should at least keep your permalinks working!

  4. Do the creation/modification dates of .htaccess change or not? Even if you see no visible changes in .htaccess?

    Permlinks are stored in the wp_options table in option_id 34 . Check them and then check after the change takes place.

    1. Delete the existing Permalink structure and set it to default.
    2. Delete the current .htaccess file.
    3. Purge your site cache.
    4. Write a new .htaccess file like @bvandrunen suggested.
    5. Create your new permalink structure again.

    That should work.

  5. You can try using the ‘try_files’ directive in the Nginx configuration file for your website:

    a) Open the configuration file present at ‘/etc/nginx/sites-enabled/yoursite.conf’ or ‘/etc/nginx/conf.d/default.conf’

    b) Then add the following lines under the location / block:

    try_files $uri $uri/ /index.php?$args;
    

    c) It should look like:

    location / {
        root   /var/www/html;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    }
    

    You may also check out WordPress custom permalinks and Nginx for detailed information.

  6. I would have to agree with @ahockley since I had this exact same problem with my WordPress blog. Which is happening is that the .htaccess file is getting overwritten and then when you set it to custom and then back to default it corrects itself for a while. What I had to do was something like this: (this is the default)

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

    Change to:

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

    Once I moved the # BEGIN WordPress out of the blocks the problem stopped. Hope this helps

  7. You may want to check server limits. We had this issue when MySQL was running out of space. When in your SSH, use

    df -h 
    

    to list files and see if anything has run out of space