10

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?

Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
Zach Smith
  • 5,490
  • 26
  • 84
  • 139

9 Answers9

4

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.

Todd Main
  • 28,951
  • 11
  • 82
  • 146
  • only problem is I can't use default permalinks on a live site like this due to the amount of traffic we get, so it makes testing any option very difficult. – Zach Smith Oct 19 '10 at 16:32
  • @HollerTrain. That is tough. I guess if there is a downtime in traffic, like 2am, that makes better sense for some testing, but depending on how much traffic your blog gets, that may not be an option. What version of sCategory are you using? Reason is, that most of the 404 reports are for versions above 0.3.0 (current version is 0.6.2). Have you tried the *Save Changes* in **Site Admin** to see if that regenerates the links and removes the 404s? – Todd Main Oct 19 '10 at 17:36
  • @HollerTrain: From the other responses and your answers (like .htaccess not getting changed), I highly encourage you to look closer at the issue of the **sCategory Permalink** plug-in as the cause here. It is a common issue with this plug-in. – Todd Main Oct 21 '10 at 22:54
  • 3
    @HollerTrain: You're overdue for a testing/development instance of your site when you feel you can't do things for fear of disturbing the traffic. – John Mee Oct 22 '10 at 02:26
  • @Otaku, how am I to fix this Plugin when our entire website is built on these custom perms, and as such I can't just change the way the article URLs are being made? what are your thoughts? – Zach Smith Oct 22 '10 at 15:15
  • @John Mee, I have dev, staging, dev2 and a mirror of the site all for testing. The issue here is you can't test for this issue on dev when no one ever goes to the site or is editing Pages/modifying the site on a daily basis. Our live site gets 10k hits a day, so I have 10k people able to test and tell me when something happens. Unfortunately I can't duplicate this on our dev site since no one is using is (except to check in code and test coding). – Zach Smith Oct 22 '10 at 15:17
  • @Otaku, i think i am regenerating the perms each time i go in and select default, then change back to custom each time which fixes the issue until they break again. if so, then would you confidently say the plugin would be the issue? if we have figured out the sCategory is the problem, then what are the steps on fixing it? just upgrading the plugin? – Zach Smith Oct 26 '10 at 23:47
  • UPDATE: seems installing Hikari Category Permalink plugin has fixed the issue for now... – Zach Smith Oct 28 '10 at 07:44
1

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.

ahockley
  • 3,696
  • 24
  • 26
  • but if it is overwriting my htaccess wouldn't the permalink settings in WP reflect a change in perms settings? when it doesn't work it still says my perms are set to custom – Zach Smith Aug 17 '10 at 19:50
  • I'm pretty sure that the WP permalink options are stored in the WP database... the screen isn't "reading" the .htaccess file. – ahockley Aug 17 '10 at 19:53
  • is there a way to just remove the option of writing/changing these values in htaccess so they never ever can be changed? – Zach Smith Aug 17 '10 at 20:03
  • Your next step is to get a copy of the .htaccess when it's working then wait for things to go bad and see if anything changed (the modification date should be changing too). If it's different the contents of the "bad" version may lead you to whatever's changing it. – Hugh Brackett Aug 17 '10 at 21:07
  • Hugh, you are very smart. It is still happening, so I will try this option and see what is changing. – Zach Smith Aug 24 '10 at 20:11
  • the htaccess seems unaffected, so the htaccess is not being changed. or at least that is not the issue at hand here. – Zach Smith Oct 15 '10 at 05:13
1

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!

Caesar
  • 577
  • 4
  • 15
  • i used chmod 644 and it happened twice yesterday and once today, and i do not see the htacess date of creation/modification changing when i view it in ftp – Zach Smith Oct 21 '10 at 21:31
  • That's strange, because the way you described it it sounded like a problem with htaccess but that implies that htaccess isn't changing... Not sure what else it could be without studying the individual setup of your blog. – Caesar Oct 22 '10 at 00:41
  • Oh wait - when you said you were getting 404s - is that the server's default 404 error pages, or a 404 from WordPress itself? (If the latter is the case it will look like the rest of your site rather than being a simple plain page.) If it's a WordPress 404 then that means the problem couldn't be with htaccess anyway; it's to do with WordPress not handling the permalink properly. That being the case it would seem to be caused by a faulty plugin; probably the sCategory Permalink plugin. – Caesar Oct 22 '10 at 00:44
  • when i get the 404 page, it is the wordpress 404 page. if sCategory Permalink plugin is the culprit, and we have a site that has been built on that structure for the past year, what are my options? I can't use a different structure at this point of the site. – Zach Smith Oct 22 '10 at 15:13
  • Ok, then htaccess is definitely not the problem, but rather WordPress or a plugin - probably the sCategory plugin as mentioned. I am not familiar with this plugin myself but, having identified this as the problem, I would suggest taking the issue up with the author of the plugin. If he can't fix it or suggest a fix; your only options would seem to be either to find a compatible replacement plugin or, if there isn't one, to write one yourself. – Caesar Oct 22 '10 at 19:34
0

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.

Mansab Uppal
  • 653
  • 5
  • 4
0

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.

markratledge
  • 17,322
  • 12
  • 60
  • 106
  • Then the file is getting not getting written to, or you don't have permissions to write to the file, or some sort of backup restore is happening. What's in cron? Do you have a sysadmin or is this webhosting somewhere and you're dealing with their tech support? – markratledge Oct 21 '10 at 22:05
  • i am technically the sys admin, so once this issue went past my head i reached to two other sys admins who are much smarter than i with this stuff, and this blows their mind and they have no idea how to fix. – Zach Smith Oct 22 '10 at 15:14
  • What's in cron? Is there some sort of backup system that runs? Is the server fully managed by you? Or is it at Media Temple of another VPS host? – markratledge Oct 26 '10 at 00:27
  • I don't know what to look for in the cron. I manage everything on the site with other programmers doing code to it. – Zach Smith Oct 26 '10 at 21:38
0

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

geoff
  • 2,251
  • 1
  • 19
  • 34
bvandrunen
  • 443
  • 1
  • 6
  • 15
0
  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.

MT.
  • 1,915
  • 3
  • 16
  • 19
0

.htaccess wasn't uploaded with my build!!!

A stupid mistake in my build process!

Tom Benyon
  • 971
  • 10
  • 15
0

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

Piers
  • 116
  • 1
  • 2