Jump to content

[SOLVED] 404 Page Not Found Help


monkeybidz

Recommended Posts

I am trying to redirect users that try to go to a page on my site that does not exist. Currently if you go to www.mysite.com it will go to the index page, if you go to a page that does not exist like www.mysite.com/rick.php it will still go to the index rather than telling user that page does not exist. This is what I have so far:

 


$request=$_SERVER['REQUEST_URI'];
        
if(!$request or $request === FALSE){
    header("HTTP/1.0 404 Not Found");
    exit();
    }

 

Any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/155576-solved-404-page-not-found-help/
Share on other sites

you can create an error page, called error.php or something, and whenever a user tries to get to a bad page, they get redirected to that page. You might be able to even make a custom 404 page on your server. Some servers let you do that

okay think about this monkey... The user goes to some random page that doesn't exist.  So how exactly do you think that that script of yours is going to execute? The only way it will execute is if someone goes to that script, and therefore it's not a 404.

 

In order to make a custom error page, you have to change a setting on the server itself.  If you have cpanel access it should be really easy for you to find.  Icon called "custom error messages/pages" or something.  You should be able to have the server load a specific target page of your choosing when 404 is triggered (or any other server code for that matter). 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.