Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

.htaccess problems - 404 WordPress

  • SOLVED

Hello again, after some more investigation... I found out more symptoms of the problem.

This is a deeply frustrating problem as I am going live on monday and I have so much more to finish over the weekend. Need help fast!

Yesterday, before roughly 20:30 GMT - my website was 100% working fine with the permalink structure set to /%postname%/ - pages were being found as normal.

At 20:30 GMT 16th Aug, I started getting 404 on all my pages.

This is like my 12 wordpress build, and I have had permalink problems in the past, and I simply fixed them with .htaccess permissions etc.

But this site was work fine in the first place, and I don't know why it started.

This time the 404 error is sporadic and makes absolutely no sense.


I have these post-types below...

Post
Page
Exhibitors
Zones
Features
Competitions


Please see below the 404 messages I get...

Post - <em>single returns 404 - but archive pages work</em>
Page - <em>page returns 404 - but sub pages work</em>
Exhibitors - <em>works</em>
Zones - <em>works</em>
Features - <em>works</em>
Competitions - <em>works</em>


How can this be????

My .htaccess contains this...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


... and is 100% writable and in the correct location. As you can see, half of my content works.

<strong>So I'm like WTF is going on!</strong>

So I basically got my server provider to run a database restore from 15th Aug - and bingo, my site is back to normal. All my pages work fine and I get no 404 messages.

I went into the permalink settings, and my website went straight back to 404 messages. And I didn't change any settings!

I again, got my server provider to run the same database restore, bingo back to normal! But in my admin, as soon as I hit the Settings > Permalink button, if screws the site up. And I havent even clicked any settings yet. It just does it.

I got my server provider just to restore the options_table in the database, and bingo - back to normal. But as soon as I hit the 'permalink' button, I get random 404 errors on pages.

So please see links below of the options_table if that helps. Before/After

[[LINK href="http://motocomdigital.co.uk/files/options_original.csv"]]This is my options_table which works[[/LINK]]

[[LINK href="http://motocomdigital.co.uk/files/options_broken.csv"]]This is my options_table after I click the 'Permalink' button[[/LINK]]



-----------------



<strong>What I did next...</strong>

I tested other themes, the all do exactly the same. So it is not theme related.

I deactivated all plugins

I migrated the website to a fresh server. I installed brandnew wordpress core files and copied all my uploads, theme and plugins accross. Run database queries to change the server name, and it does exactly the same.

So it's nothing to do with themes or core files. Then what can it be?


Any help please, please don't take offense if I can't reply to everyone.

Money will go to working solution.



-----------------------------------------------------------------------



<strong>MY ORIGINAL QUESTION</strong>


Something is up with my site and I can't figure out what happened and I can't seem to get it back to how it was.

My .htaccess file, which is in the 'Site Address (URL)' folder location, is writable 777.

For some reason now I can't get the permalink structure /%postname%/ to work? - <em>Post name</em>

It was working fine, but for some reason all my pages including posts started showing my 404.php page.

But now when I update my permalink stucture, it says the .htaccess is not writable, when it is.

OK, so I copied the code into my .htaccess anyway and I still get 404 for all pages.


Can database have anything to do with this? My pages work fine if I go back to the default permalink structure, but I can't figure out why I just 404 for every thing.

My .htaccess looks like this..

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>


But wordpress will not write this for me, I have to manually put this in.

But if I delete the .htaccess contents, and leave a blank file in place. Then I get my Apache server page cannot be found. Which theoretically means wordpress is using the .htaccess, but not doing what it is suppost to...

<strong>Aaaahhh
</strong>

Has anyone experienced anything like this? Please help.



<strong>OK, things I was doing when this happen, which was either 2 things...</strong>


1. I installed a plugin: [[LINK href="http://wordpress.org/extend/plugins/wordpress-meta-robots/"]]http://wordpress.org/extend/plugins/wordpress-meta-robots/[[/LINK]]

Once I noticed pages were showing 404 I deactivated it and still I was getting 404, so I cant see this being the issue.

2. I was working on duplicate test site on another server, which had my ftp credentials for broken site, in the functions.php...

define('FTP_USER', 'example_co_uk_2');
define('FTP_PASS', 'fyvTrfMpLUdR');
define('FTP_HOST', 'dev.example.co.uk');
define('FTP_SSL', false);


Accidentally these ftp credentials above are for my broken site, not for my duplicate test site. So I deleted this when I spotted this, but I thought this would only affect plugin installations from 3rd party stuff??

But the duplicate test site database is completely separate, and is not connected my broken site - so anything that I may have changed on the duplicate test site surely couldnt affect my site?



And thats it... The site was working perfect before this.

Answers (6)

2012-08-17

Arnav Joy answers:

try two things:-

1. Switch to twentyeleven or twentyten theme and then test it.

or

2. keep the full backup of your site including db then reinstall wp again and then install the plugins one by one and see.


Josh Cranwell comments:

Interesting....

Switch to my twentyeleven theme and the permalinks structure works?

How can this be related??


Arnav Joy comments:

if this thing happening then there must be any code in your theme that is overriting default behaviour , check your theme for any rewrite rule , specially functions.php or share it here


Josh Cranwell comments:

Hi

I just discovered that all my custom post types work fine???

It's just pages and post that get 404.

It is a bit suspect that this plugin below only works for posts and pages...

And when I installed this, all these problems started...

http://wordpress.org/extend/plugins/wordpress-meta-robots/


I can't run a restore database backup because there are other server backups qued..


Arnav Joy comments:

try this plugin
http://wordpress.org/extend/plugins/wordpress-seo/


Josh Cranwell comments:

Sure this won't fix my 404 will it?


Arnav Joy comments:

i am not sure , i have not tested it .. sorry i should have say this before


Josh Cranwell comments:

Are you around to PM you?


Arnav Joy comments:

can you provide me access to your site?

2012-08-16

Abdelhadi Touil answers:

Hi.
I think it's a problem with .htaccess file permession, sometimes server dos not let us to change it, so after changin permession to 777, refresh your files via FTP and see if it's really 777.
I sugest to create a new .htaccess file (not just delete the current .htaccess content), create a blank new one, and make it 777, then resave your permalink structure via wordpress admin.
Hope this helps you. Sorry for my bad English.
Good luck.


Josh Cranwell comments:

Thank you for the advice.

I did try this, I deleted .htaccess, made new ones. Tried a couple ftp clients like cyberduck and espresso. Refreshed permissions and definitely was changing (so it says)

I will contact my server guy tomorrow morning and see if he can see any problems with it. I never had this problem before and for it to just start. Very weird.

I'm off to bed but will pick this up in 7 hours.

Thanks


Abdelhadi Touil comments:

You are welcome. Good night.

2012-08-17

Asad Iqbal answers:

Which server you are running now? Apache or nGinex?


Josh Cranwell comments:

Apache for sure..


Asad Iqbal comments:

This may cause for apache configuration. Please ask your hosting provider.

2012-08-17

Pali Madra answers:

I would suggest deleting the .htaccess file.

Create a new blank .htaccess file.

Upload it to the root of the server.

Change the permissions to 777.

Now re-save or change the permalink structure and then save it.

The website should be working fine now.


Josh Cranwell comments:

Nope... still working...


OK I've established this...


These are my General settings...


WordPress Address (URL)
http://dev.example.co.uk/wp

Site Address
http://dev.example.co.uk/


But wordpress is not writing the .htaccess in the 'Site Address' - it is writing one in the 'WordPress Address (URL)' location???


How can this be happening???


Pali Madra comments:

Hello Josh

Please remember that

- The "Home" or WordPress address (URL) setting is the address you want people to type in their browser to reach your WordPress blog.

- The "Site URL" or site address setting is the address where your WordPress core files reside.

Is this correctly defined in your installation? Please confirm.


Josh Cranwell comments:

Are you sure...

It is the opposite way round I thought?

[[LINK href="http://imgur.com/k9Pqp"]]See this screen shot[[/LINK]]


Pali Madra comments:

Please refer to the codex at http://codex.wordpress.org/Changing_The_Site_URL


Josh Cranwell comments:

Yeah hard coding it made no difference.

2012-08-17

ej_emman answers:

Hello Josh,

Based on what you said.

<em>"Switch to my twentyeleven theme and the permalinks structure works?"</em>

This gives an idea that there is a conflict in the functions of your template.

I also think that http://wordpress.org/extend/plugins/wordpress-meta-robots/ , this plugin

nothing wrong with your website.

I suggest to paste the function codes. So that we can trace up where does it goes wrong.


Cheers,


Joseph


Josh Cranwell comments:

Thanks for your comment, Arnav had a look and after indepth testing it was a dodgy register_taxonomy function.

2012-08-17

philip answers:

OK, my guess is that this is a software upgrade related problem.

e.g. if your host has updated their version of PHP recently you could get exactly this sort of problem.

Although it sounds like it is .htaccess issue, the pattern (certain post types show) suggests not.

2 other things you could do:

1) disable all plugins and re-enable one by one

2) in wp-config.php set WP_DEBUG to 'true' and check the output. Those 'warnings' should be diagnostic.

Post them here or a live link to problem pages with debug on and someone here no doubt will be able to help.

BUT if - as you say Twenty Ten works - the previous contributor is probably right and there will be some deprecated PHP function in your theme that is messing it up, most likely lurking in functions.php.

The explanation of the sudden change being some software update by your host.

Hope that helps a bit.


Josh Cranwell comments:

Thanks for your comment, Arnav had a look and after indepth testing it was a dodgy register_taxonomy function.