Moderator
James Huff
(@macmanx)
Volunteer Moderator
You need to add a line to .htaccess for this. Create the following line (using the correct path to your 404.php file) and add it to the .htaccess file in your site’s root directory:
ErrorDocument 404 /wp-content/themes/default/404.php
Thread Starter
S.K
(@kichu)
Thanks, macmanx.
But why not the error page be called, like it does in the case of /index.php?error=404 is my question!
When the query string is changed for other files, I think this 404.php also should be called likewise, as otherwise the paths to include files becomes a problem.
Hope I have stated my problem properly.
Thanks and regards
S.K
http://blog/cyberbrahma.com/
ErrorDocument 404 /index.php?error=404
With that, if a mod_rewrite rule is not matched, Apache tells WP to load the 404 page for the active theme. The ErrorDocument line is not added to .htaccess by default.
If a mod_rewrite rule matches but the resultant query does not match any posts, WP loads the 404 template. If you use PATH_INFO permalinks and if either an internal rewrite rule doesn’t match or a query doesn’t resolve to any posts, WP loads the 404 template.
There are several 404 scenarios, ErrorDocument in .htaccess only handles the case where no mod_rewrite rules are matched.
Thread Starter
S.K
(@kichu)
Thread Starter
S.K
(@kichu)
Thanks rboren.
<quote>If you use PATH_INFO permalinks and if either an internal rewrite rule doesn’t match or a query doesn’t resolve to any posts, WP loads the 404 template.</quote>
But I use PATH_INFO permalinks. And I expect the 404 template from the active theme folder to be loaded (when 404 situation occurs), but it doesn’t take place.
Now, in dummy’s terms, if PATH_INFO permaliks are opted, the default 404 template will not be loaded unless its path is defined in the errorDocument statement of the .htaccess file.
Am I right in my postulate?
Regards
S.K
Moderator
James Huff
(@macmanx)
Volunteer Moderator
No, actually I quoted the wrong ErrorDocument rule. Sorry for the confusion. If permalinks are active, the .htaccess line should still be:
ErrorDocument 404 /wordpress/index.php?error=404
ok,
there has to be a simple thing I am missing.
in .htaccess I have:
ErrorDocument 404 /wp-content/themes/default/404.php
the error I continur to get is:
Fatal error: Call to undefined function: get_header() in ../../../../../../……default/404.php on line 1
Help?
Thanks!
T
Ok,
several attempts have resulted in success.
.htacces required this:
ErrorDocument 404 /index.php?error=404
Now – no errors in the 404.php document!
Yeah!
How many hours can it take to work something so simple out?
Well, it was fun anyway 🙂
Hi guys, i tried the ErrorDocument 404 /index.php?error=404 solution, but what happens is if i have a link that goes like http://myhost.com/chicken – it’ll show up a 404 page. but if i have a link that goes http://mohost.com/chicken.php – it says “No input file specified.” and not the 404 page.
if i didn’t have the ErrorDocument line, the server won’t redirect to the WP’s 404 page in my theme but the generic 404 error message.
any suggestions?
thanks.