Forum Moderators: phranque

Message Too Old, No Replies

wrong custom 404 showing

showing the wp 404 on entire site when I want it to show a general one

         

LisaWeber

2:04 am on Mar 16, 2006 (gmt 0)

10+ Year Member



I have a wordpress blog within one directory of a site. Several directories deep within this directory is 404.php from the theme.

I have a custom 404.html in root, and in my .htaccess file I have this

ErrorDocument 404 /404.html

But in any directory, if I visit a nonexistent page, I get the directory/subdir/subdir/subdir/404.php

What's going on? How do I fix? thanks.

lammert

2:40 am on Mar 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You have probably a new version of WordPress. Somewhere in the .htaccess you can find the code:

RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule . /somelocation/index.php

This code is added when you chose search engine friendly URLs in WordPress. It causes all requests which do not match a physical existing file or directory to be forwarded to the main index.php file of WordPress. The URL is there processed and if the URL cannot be interpreted the WordPress custom 404.php is called.

When I used version 1.2 of WordPress it generated many user defined rewrite rules in the .htaccess, but the newest version uses this bulk approach which also catches non existent files for other directories if this line happens to be present in your root .htaccess file.

This is a common method for many CMS systems nowadays, because there is no need for them to manipulate the .htaccess files. The good thing is that WordPress returns a proper 404 error code when it cannot resolve a URL. I have had massive duplicate problems with Mambo which always returns a 200 OK code, even if a URL cannot be decoded. I ended up with disabling those three lines of code and replace them with my own bulkier rewrite rules.

LisaWeber

2:45 am on Mar 16, 2006 (gmt 0)

10+ Year Member



thank you lammert. I do have that in my code, and your succinct explanation makes perfect sense.