Wordpress Permalinks Not Staying - wordpress

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?

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.

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.

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!

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.

Delete the existing Permalink structure and set it to default.
Delete the current .htaccess file.
Purge your site cache.
Write a new .htaccess file like #bvandrunen suggested.
Create your new permalink structure again.
That should work.

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.

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

.htaccess wasn't uploaded with my build!!!
A stupid mistake in my build process!

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

Related

Wordpress Error 404 after changing permalink on some pages

I’m having a problem since changing my permalinks from default to postname on a wordpress site. I’m getting 404 errors on pages but only the ones that are within the submenu called menus, all the other pages are working fine.
I have been searching on and off for an answer to this for a couple of days now with no success. Someone suggested that it might be an error in the HTaccess file but I don't really know what I'm looking at. I tried generating a new one from Wordpress.org code I found but that just killed the site altogether so I changed it back to the old one. I can see the .htaccess inside the folder public_html there are some others in there with .bak which I assume are from backups I've made of the site. Here is a link to what I'm getting http://www.5thview.com/menus/nibbles/
Not sure why it’s just those pages that are affected other than they are in a submenu. I’ve no idea how to fix this.
I should add that if I switch back to default permalinks it works fine again…
I would need specific instructions if poss as I'm a bit of a newb to the coding side etc although I can find my way around if directed...
Any help would be greatly appreciated. Thanks...
The reason links are broken is that your host doesn't have root directive correctly set.
If you are using Nginx, change the virtual host conf file as below:
server{
location / {
try_files $uri $uri/ /index.php?q=$uri$args;
}
}
If your root wordpress is not the webroot but http://[domain.com]/wordpress/:
server{
location /wordpress/ {
    try_files $uri $uri/ /wordpress/index.php?q=$uri$args;
}
}
Don't forget to restart nginx service.
If you are using Apache, put .htaccess file under your root path, an add below lines
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Don't forget to restart apache service.

WordPress Home Folder (Default) Issue

I've recently relocated a WordPress site to a new host. I followed the instructions from here and things seemed to go ok. However on the old host the installation was inside a sub-folder (news). On the new host I want it in the public_html folder. All files are up, I have made the appropriate changes to the wp_config file, I have edited the .htaccess file and removed any references to the old path, I have even gone into the wp_options table and made the url changes there.
However for some reason whenever I reference the index.php, it tries to point back to the old sub-folder location. I've looked in the wp-settings, wp-load files etc and for the life of me cannot find where the bad path information is.
I've gone to the wordpress.org site and several other sites, any help would be appreciated.
UPDATE: I deleted my wp_config file and the system asked me to setup, so I did. During the setup it recognized that the database was there, etc, and sent me to the login. I was able to login, looked at the settings, etc and they are all as they are supposed to be.
If I go directly to wp-admin or wp-login it lets me log in with no problem. however when I try to go to the site, nothing, however instead of showing the old url, it now shows a blank screen.
Thanks
First of all make sure that your whole database does not contain any references to the old installation otherwise some redirection may be active. For migrating your database nowadays you use the following tool to make sure that also serialized data does not contain any references to the old URL:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Can you reach your backend? If only the frontend does not work its probably a permalink problem update your permalinks by going to Settings -> Permalinks -> Save (Update)
Check your index.php and the index.php file from the main directory and also from the subdirectory if there any redirection is active
Do a search (and replace) for the content of all files within your WordPress installation and check for any possible hardcoded redirection
It MUST be one of those problems.
If still no success debug your WordPress installation step-by-step (with echo "reached"; die;) to find out WHEN the redirection is happening - important points to check:
index.php file
wp-config.php file
Action Hook 'init'
Action Hook 'template_redirect'
This might also be helpful: http://rachievee.com/the-wordpress-hooks-firing-sequence/
Check your .htaccess file.
You probably have something that looks like this(notice the subfolder):
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
# END WordPress
When you should actually have something that looks like this:
# 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
First although neither of the two posted answers solved the problem, they both were instrumental in helping me figure out what was wrong, so I voted each of them up.
Since I could log into the admin area, I knew things were pointing to the correct place. But I was still getting a blank page, well it turns out that somehow in the ftp transfer of the backup site to the server, the 'themes' folder didn't make it. Once I uploaded that folder, things are close to being back to normal.
Again, the advice I received helped me tremendously in troubleshooting this sucker. Thanks

Wordpress erasing .htaccess - gets stuck in redirect loop

I installed Wordpress to the root of my site using Scriptaculous and found I was unable to access it due to a redirect loop. My address bar would look like http://site.com/site.com/site.com...
I found that there was no .htaccess file for this site so created one by copying it from another WP install:
# 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
This made my site work. However I've found that some actions in the dashboard totally erase the htaccess file so it looks like this:
# BEGIN WordPress
# END WordPress
Changing permalinks did this and it seems that sometimes when trying to edit a page it does it too. When the .htaccess file looks like this the site gets stuck in a loop again until I copy back the old info. Any suggestions for me?
It sounds like a plugin or your theme is messing around with the rewrite rules and the htaccess file.
Disable the cache if any (there's a define in your wp-config.php file if you're using one), all plugins and revert to one of the built-in themes, then reenable things one by one until you spot the one that is breaking things (your caching plugin is a good place to start).
If you can't access the admin area because of the same issue, temporarily rename the plugins folder to e.g. plugins-disabled to reset the active plugins.
Are you using some cache plugin ? If so then check if it's recently updated because i also faced same issue and i was using w3 Total cache - On my side problem occured because of updating w3 total cache but just emptied cache and re-activated, reconfigured it.
Moreover, you need to check if your Theme or some other Plugin is causing this problem i.e. changing rewrite rules.
Try what Denis said & i hope that will help as well.

Migrating Wordpress blog from www.site.com to newdomain.com/blog

I am planning on migrating a blog that is currently hosted at
www.blog.com
to a subdirectory in a new domain such as
newdomain.com/blog
So far I've seen several tips on how doing this and [in particular from Yoast (Joost) is helpful but not identical to my situation 1.
Any suggestions?
The main steps on Joost's article are as follows:
[1 ] Edit wp-config.php
define('WP_SITEURL', 'http://www.newdomain.com');
define('WP_HOME', 'http://www.newdomain.com');
[2 ] Use the Search and Replace plugin to replace old URLs
[3 ] Update .htaccess to
Redirect 301 /blog/ http://www.newdomain.com/ // <== note this is NOT my situation
// I likely need the reverse
However, this won't address my particular need, in which a different change in .htaccess and wp-config.php may be necessary.
Any suggestions?
Wordpress has some RewriteRules that it wants to use in an .htaccess file. It should look something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I think that all you need to do is take this and place it in an .htaccess file in your document root (where http://www.newdomain.com/ is). If you don't have any special rewrite rules or options in your .htaccess file, you could just move the file out of /blog/ and into /. You don't want these rules in both places.
Then in wordpress' admin panel (you'll need to go here: http://www.newdomain.com/blog/wp-admin/options-general.php ) there are 2 fields, one for WordPress address (URL) (this should say http://www.newdomain.com/blog/ ) and one for Site address (URL) (this should say http://www.newdomain.com/ ). And I think that's all you need to do.
If you are using custom themes you may want to double check any absolute URIs you have in the headers/footers/etc.
There's some more information about doing this here: Giving Wordpress It's Own Directory
EDIT: I forgot to mention that you need to create an index.php in your document root. In the link above, under the section Using a pre-existing subdirectory install, you need to follow the steps to create an index.php. You only need 2 lines.
As for the code-igniter/wordpress conflict. You may need to get the 2 rules to jive with each other, and that may not be so easy to do. You either have to move code-igniter's rules into their own directory or use RewriteCond to make sure they don't step on each other. For example, adding a RewriteCond !/index.php so wordpress' rewritten URI won't get re-rewritten by code-igniter's.
I would suggest a clean install. Just export your blog posts as XML, and copy over the uploads.

Wordpress: Permalinks for pages broken

I'm using Wordpress 3.1.1 and recently reorganized my page (deleted and moved a lot of pages). Now I get 404-errors when accessing some pages (all posts and tags work fine).
I can disable the permalinks and then access all pages without problems. I can also rename the pages (e.g. contact --> contact1) and all links work again for the new names. However, if I rename them back, I get the same 404 error again. It seems like some kind of caching-problem. Any ideas how to fix it? Thanks!
My .htaccess for the root directory:
# 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
Try clearing your 'trash' can in Wordpress, annoyingly items in the trash area still use a permalink, and when accessing those links you'd get 404 message.
Also delete your htaccess file (if it has no additional settings in it), and the reset your permalink settings.
Ian.
I finally solved it. I realized, that there were some page names, that produced a server 404 and some, that don't. Then I took a closer look at my directory structure:
I access my blog from the root path (not the worpdrpess-directory which is located in it). So I can enter
www.myurl.com
instead of
www.myurl.com/wordpress
So far, so good. However, I had some files in my root directory, that had the same name as the page I was trying to access.
Eg. if there is a contact.abc (the extension doesn't matter) in the root folder, then getting
www.myurl.com/contact
will produce a 404-error. If I rename the file everything works fine. Hopefully, that will help others as well.

Resources