Forum Moderators: coopster
Hope I can make my point here with just a few words. If you go to Google's site or Apple's site and put /adasdaksjdaskhjdaskjdhasjhkdasjhkdashjkdaskhjda (something random), you will probably be redirected to a custom "Page Not Found". That is a pretty cool web development trick and I would like to ask you guys if you know how to do this using PHP...
When a user visits mysite.com and puts /something that cannot be found in my server he just sees the boring "Server not found" message of their browser. If I could write a custom "Page Not Found" script for my site that would be pretty awesome, but I have no idea how to do this
Thanks a lot in advance!
use this in your htaccess file
ErrorDocument 404 http://www.example.com/custom_page.html
and make this custom_page.html as beautiful as you want :)
[edited by: eelixduppy at 7:32 am (utc) on Nov. 17, 2007]
[edit reason] changed to example.com [/edit]
I just tested by doing www.MySite.com ( my site ) + /asdjkasldashdasldashldk/ (some random destination) and it returned to that error.html page, because the weird destination doesn't exist.
Did I miss something? What do you mean by "meta-refresh" and "404 response status code"?
Did I miss something? What do you mean by "meta-refresh" and "404 response status code"?
if you don't have "meta-refresh" somewhere in your page don't worry about it.
however...
be sure that FIRST THING, before all that purdy stuff in your cool not found page, before the doctype or html tag or whatever, you start with the following:
Status: 404\n\n
(those two "\n"s would be 2 newlines)
that way your browser knows that even though it has some content to display, it actually represents content that was not found.
it should leave your url in the address bar pointing to the missing content instead of the url of the error page, for example.
it also tells the search engines not to index that content for that url.