PHp In Wordpress

SitePoint Members (Happy New Year !!),

In wordpress, Im trying to change the file name of my file for 404 error mesages.

I changed the line in my .htaccess file

ErrorDocument 404 /404.php

to say
ErrorDocument 404 /z404.php

and I changed the file name to z404.php

What else do I need to change to get this new adress recognized, becaue the changes above aren’t enough because my error page doesn’t come up when I type some gibberish after the home page address.



Your .htaccess file redirects all requests to index.php so that WordPress can serve your site. Technically virtually all URLs except for the root of your site are file not found errors – there’s not really a file called /2009/1/3/post-name even though that’s the URL shown if someone reads a WordPress post written on that date.

So if you want to change the content of the 404 message, which is generated by WordPress when it can’t find content matching the requested URL, you need to do so within WordPress as well. This is handled through the 404 template of your theme; if it doesn’t have one, you can create one. Create a file called 404.php and put it in the theme’s directory.

In “ErrorDocument 404 /404.php” 404.php is a real file in my theme. Also, Im really not trying to change the content of 404.php, just the file name (e.g. z404.php). Any ideas?


/404.php is not a path within your theme, because all themes are below /wp-content/themes/ …

The ErrorDocument directive is irrelevant, because there is never a real 404 error occurring at the server level, all requests are being sent to WordPress. index.php is found, so as far as Apache is concerned, there is not a file not found error occurring.

It’s WordPress that outputs an error when there’s no content at some fictional URL – and WordPress uses the 404.php file within the theme to do so.

You can’t change this file name, the organization of the template hierarchy is part of the WordPress core, not something user configurable.

Are you saying /404.php is not a path within my theme or no one’s theme?


SitePoint Members,

I’ll try this question on another forum.


Hey Lindaro,

You’ve almost done this properly, you’re just missing a few steps.

First you’ll need to make sure that you have the 404.php file in your wp-content/themes/(yourtheme) folder.

Most of the time wordpress will pull up this 404 file if it can’t find a post, but if you’re wordpress is not behaving then let’s move on.

Let’s turn your 404 document into a wordpress template, add this line to the top of your 404.php file

Template Name: 404 Error
Now create a new PAGE from your wordpress admin panel and call it 404 Error. If you’re using your permalinks then you’ll see the new link to your error page, it will look something like.


Finally, in your .htaccess file you’re custom error code will need to reflect this new URL:

Begin Error Document Redirection

ErrorDocument 400 /404-error
If this did or did not work for you let me know.