Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Creating an Error 404 Page

This is a draft. I'm new here, feel free to set me straight on procedures. This is nearly finished except for links and the section on writing friendly messages.


Thanks for your contribution. Did you read through the Codex Guidelines and tips on helping? There is a lot of good info there, so make sure you take time to go through it. It's a general guideline to create these articles within your user page first before putting them in the general pages so they can get edited and cleaned up before going "public". The other is that all discussions about the article are done on the discussion page, like what you are reading. We also like it when you let us know what you are going to do on the wp-docs mailing list so there isn't any duplication of effort. And lastly, if you would sign your discussion posts with four tidles (~) which creates a "signature" and time stamp and helps us keep track of who you are and when you posted your comments. Little things.

My name is Lorelle and I'm the kinda assistant editor behind the Lessons Pages so I'll be going through this and cleaning it up. Please remember that the bottom line in the edit screen says don't put anything here you don't want edited without mercy, so please know that all of the work here is done without blame and ego, only to inform and educate you, as a contributor, and everyone else who reads this work.

I will probably have a few questions for you, so I hope you will create a user page so I can leave a message for you (sign something and then click on your name and type in a little about yourself and a link to your web page so we can contact you) and check here to see if I've posted any questions for you.

Thanks again and I look forward to seeing your great contribution! Lorelle 19:46, 23 Apr 2005 (UTC)


I did a bunch of cleaning and some rewriting, which I normally wouldn't do so much but we have a big press release coming out on the WordPress lessons in a couple days and this is too critical an article to leave alone. And you've done a fabulous job!
As background information, the WordPress Lessons differ from the rest of the Codex documentation in that they are conversations more than 1, 2, 3, A, B, C instructions. It's more as if one of the Forum volunteers was sitting down and talking to someone in person, making a little joke here, some fun there, but getting on with seriously answering their questions in a more conversational, informal way. I added some of that "voice" to flesh out the topic.
The last bits at the bottom of the article feature some other errors, but they leave us asking "What do I do with these?" Should the user create a 500.php page to deal with those? We just need some information on what can be done with these, or explanation on how WordPress really deals with them. If you don't have that information, let's remove it totally as they don't need it and they can ask in the forum if they don't know. Why bring up questions they don't need to ask ;-).
Also, can you add, probably just after Useful Links, a section on putting the search template into the 404 page, something commonly done and very useful.
Really good work and I'm looking forward to MORE!!!!! Thanks so much. I've been asking for this article to be done for a while and you are a star for doing it! Lorelle 20:36, 23 Apr 2005 (UTC)

Question about 404.php being called by default.

WordPress will not automatically use that 404.php page if a Page Not Found error occurs.

Default wordpress set up without htaccess using default theme (which has 404.php) it will not use the 404.

http://www.stdp.org/list/news/brokenlink.php

Even if you create a post that has a broken link, the 404.php will not be used without installing the htaccess file:

http://www.stdp.org/list/news/?p=2

But once we set up the htaccess, all is peachy. I don't have a 404.php for the Landzilla theme so it goes back to index.php by default. That's because the htaccess tells it to go to 404.php, but handles it nicely if it's not there. Because WordPress is very polite.

Here is a link that (if you use the cub reporter or WordPress Default theme) will find it's 404.php.

http://www.reportica.net/news/brokenlink.php

You need that htaccess, unless i am wrong. then you don't...

Sheryl

http://codex.wordpress.org/template_hierarchy Explains that by default, WordPress will automatically use the 404.php page if a page not found error occurs. I'll check with the developers but read this to see what they have to say. If there is no 404.php, then it returns the index.php and the Not Found error that is in the Loop.
If you have a custom 404 page that isn't titled 404.php but brokenlink.php, then it requires htaccess to redirect to the non-standard 404 page. But I'm only reading the documentation. I'll double check on this for you. Lorelle 12:56, 26 Apr 2005 (UTC)
Confirmed. It's automatic: 404.php then index.php. For custom named pages, these require an htaccess error entry. All of this gets so complicated.....hee hee. Lorelle 13:17, 26 Apr 2005 (UTC)

Are we talking about 1.5??

Here is an example of a recently installed (1.5) WordPress where a call to a non-existent file does not call 404.php (if the htaccess was set up, yes, it would then revert to index.php if this theme did not have a 404.php.)

http://www.stdp.org/news/brokenlink.php

I never had any file called brokenlink.php, I use that url to produce a 'file not found' error.

You can also see that a WordPress page that calls that nonexistent file produces the same error. This one has the default theme. It does not call 404.php even though the file exists.

http://www.stdp.org/list/news/brokenlink.php

Another one of my sites, not calling 404.php by default, even though it is a new standard installation using the default theme:

http://www.hearthandhome.net/news/nonexistent-file.php

I believe this is because the htaccess is not set up, as it is at reportica.net:

http://www.reportica.net/news/brokenlink.php

Unless I am doing something non-standard, htacess is required for 404.php to be called by 1.5.

Sheryl

I am absolutely sure it does not work with 1.5.x. 2.0RC1 seems to have the automatic 404.php feature out of the box. -- Nils 21:47, 18 Dec 2005 (GMT)

This is the page I'm working on http://sculptmydog.com/ and if I click on the links About, Archives and Contact it sends me to the 404 page, but I don't want to see the 404 page I want to see and actually page. Like this http://sculptmydog.com/?page_id=2. And I found this in the header page

Is this where I would direct it to the link and if so how?



Unless I'm mistaken I believe the section on "Help Your Server Find the 404 Page" is misleading. I think once the user has Pretty Permalinks enabled then the suggestion of adding:

ErrorDocument 404 /index.php?error=404

to your .htaccess file is incorrect and this will actually result in the server directing the user to the website's home page. I believe with Pretty Permalinks on the .htaccess file should point to:

ErrorDocument 404 /404/

Unless it's a question of where in the .htaccess file this rule is placed - either way this section needs some clarification.

I thought I'd look for discussion before going ahead an editing. --Alex 02:06, 26 January 2009 (UTC)