FRIHOSTFORUMSSEARCHFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Displaying A Default Page Not Found.

 


cr3ativ3
Is there any way in php or similiar languages like javascript, to have it display the default 404 message for that browser when something happens. Like, in php say I have sessions set up and if the person is not logged in the page that the user visits that you need to be logged in to, it displays the users browsers default 404 message.

I know I could always have it check the browser type then redirect them to a file on the server that mimics that browsers 404 not found but I am trying to find out if there is any other way like a function or something built into the language.

Thanks
MrBlueSky
Here you go:

Code:

<?php
header("HTTP/1.0 404 Not Found");
?>



Note: this doesn't always work. See: http://nl3.php.net/manual/en/function.header.php#70236
cr3ativ3
Oh, thanks now I feel dumb.
bgillingham
Anywhere in my code when I need to serve up a 404 page manually, I simply use
Code:
 include("404.php");


My 404.php file uses my database to look for pages that they may have meant to go to -- and even redirects them to the correct page. On top of that, if I set a variable such as $enabled in my parent code, I can access this in my 404.php to render a specific page based on disabled items.

It goes without saying that the 404.php file, where appropriate should include :
Code:
    header("HTTP/1.1 301 Moved Permanently");
    header("Status: 301 Moved Permanently");
    header("Location: ".$redirectAddress);

Code:
   header("HTTP/1.1 404 Not Found");
   header("Status: 404 Not Found");

...or other headers that I don't use -- you may need to serve up 403 Forbidden headers.
manum
find more custom error page scripts at www.hotscripts.com

and java script and php are similar in no manner please.......
Related topics

[RESOLVEd] How to set the default page ?
(official) IE 7 Topic
General .htaccess tutorial.
Funny errors of IE
default files sequence

Problem index page
How to create polls on your website?
Making a file the home page
Accounts from Server 2 being moved to Server 3
Checking for values in database and displaying error page

help me plz
Simple PHP Navigation
how to make a SITE on ftp not a forum
Cross-Browser Compatability
My Blog
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.