views:

245

answers:

6

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?

+1  A: 

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
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
HollerTrain
I'm pretty sure that the WP permalink options are stored in the WP database... the screen isn't "reading" the .htaccess file.
ahockley
is there a way to just remove the option of writing/changing these values in htaccess so they never ever can be changed?
HollerTrain
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
Hugh, you are very smart. It is still happening, so I will try this option and see what is changing.
HollerTrain
the htaccess seems unaffected, so the htaccess is not being changed. or at least that is not the issue at hand here.
HollerTrain
+5  A: 

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.

Otaku
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.
HollerTrain
@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?
Otaku
@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.
Otaku
@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
@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?
HollerTrain
@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).
HollerTrain
@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?
HollerTrain
UPDATE: seems installing Hikari Category Permalink plugin has fixed the issue for now...
HollerTrain
A: 

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.

songdogtech
no the creation date still says it as Sept 28, 2010
HollerTrain
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?
songdogtech
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.
HollerTrain
Windows or linux server?
songdogtech
LINUX server...
HollerTrain
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?
songdogtech
I don't know what to look for in the cron. I manage everything on the site with other programmers doing code to it.
HollerTrain
@songdogtech, seems to be here (http://screencast.com/t/MNzWhJQkfwhR).
HollerTrain
+1  A: 

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

bvandrunen
+1  A: 

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!

caesarsgrunt
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
HollerTrain
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.
caesarsgrunt
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.
caesarsgrunt
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.
HollerTrain
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.
caesarsgrunt
A: 
  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
when you say 'create your new permalink structure again' is this just clicking 'default' and typing in my custom perms?
HollerTrain
Settings -> Permalinks -> Custom Structure: /blog/%scategory%/%postname%/
MT
Also, don't forget the forward slash "/" before "blog"
MT