Forum Moderators: phranque
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.
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.