Wordpress Permalinks Not Staying
Asked Answered
A

9

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?

Anthurium answered 17/8, 2010 at 19:23 Comment(6)
What is your custom permalink pattern?Kathernkatheryn
Do they all stop working or just certain ones? If it's just certain ones, give some examples.Acetometer
@gclaghorn: blog/%scategory%/%postname%/ $hugh: only Posts stop working - pages works fine.Anthurium
@HollerTrain: that s in the %category% shouldn't be there, should it? I cant find any mention of a %scategory% tag in the WP docs.Kathernkatheryn
@gclaghorn: that is custom per client ;( i doubt that is the issue.Anthurium
This is an ideal question for the WordPress stack exchange site. wordpress.stackexchange.comScabrous
L
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.

Leralerch answered 15/10, 2010 at 17:14 Comment(8)
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.Anthurium
@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?Leralerch
@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.Leralerch
@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.Malines
@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?Anthurium
@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).Anthurium
@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?Anthurium
UPDATE: seems installing Hikari Category Permalink plugin has fixed the issue for now...Anthurium
J
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.

Jeer answered 17/8, 2010 at 19:42 Comment(6)
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 customAnthurium
I'm pretty sure that the WP permalink options are stored in the WP database... the screen isn't "reading" the .htaccess file.Jeer
is there a way to just remove the option of writing/changing these values in htaccess so they never ever can be changed?Anthurium
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.Acetometer
Hugh, you are very smart. It is still happening, so I will try this option and see what is changing.Anthurium
the htaccess seems unaffected, so the htaccess is not being changed. or at least that is not the issue at hand here.Anthurium
S
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!

Swen answered 21/10, 2010 at 18:5 Comment(5)
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 ftpAnthurium
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.Swen
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.Swen
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.Anthurium
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.Swen
H
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.

Homestead answered 17/10, 2010 at 17:55 Comment(4)
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?Homestead
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.Anthurium
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?Homestead
I don't know what to look for in the cron. I manage everything on the site with other programmers doing code to it.Anthurium
G
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

Garett answered 20/10, 2010 at 22:10 Comment(0)
M
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.

Mastodon answered 21/10, 2010 at 20:4 Comment(3)
when you say 'create your new permalink structure again' is this just clicking 'default' and typing in my custom perms?Anthurium
Settings -> Permalinks -> Custom Structure: /blog/%scategory%/%postname%/Mastodon
Also, don't forget the forward slash "/" before "blog"Mastodon
V
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.

Vargueno answered 12/2, 2013 at 19:43 Comment(0)
D
0

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

A stupid mistake in my build process!

Diandrous answered 10/5, 2018 at 15:10 Comment(0)
T
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

Toe answered 9/3, 2021 at 12:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.