monkeybidz Posted April 25, 2009 Share Posted April 25, 2009 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. Quote Link to comment Share on other sites More sharing options...
mikesta707 Posted April 25, 2009 Share Posted April 25, 2009 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 Quote Link to comment Share on other sites More sharing options...
monkeybidz Posted April 25, 2009 Author Share Posted April 25, 2009 I do have an error.php page, but for some reason it will not go to it all the time. Quote Link to comment Share on other sites More sharing options...
.josh Posted April 25, 2009 Share Posted April 25, 2009 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). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.