atomicrabbit Posted March 8, 2009 Share Posted March 8, 2009 Ok so .. as basic as I can put it, I have an index.php page that accepts a value for the parameter "p". So index.php?p=whatever Is it possible to have it go to a 404 error page if the "whatever" is not found? Currently, I'm using a php switch, so... $page = $_GET['p']; switch ($page) { case "one": //do something break; case "two": //do something break; case "three": //do something break; default: header("HTTP/1.1 404 Not Found"); header("Location: 404.php"); break; // continue some code But that code just redirects to the 404 page and it changes the URL in the address bar and the $_SERVER['REQUEST_URI'] is changed to the 404.php page, instead of the page that was requested. Whereas if the URL that was entered was hxxp://www.domain.com/page-that-doesnt-exist.html, the URL in the address bar would not change and still go to the error doc that is defined in the .htaccess file and the $_SERVER['REQUEST_URI'] would be "/page-that-doesnt-exist.html" Basically: Is there a way to tell the server that the page doesn't exist if a php page's parameter is incorrect, without redirecting using a header("Location: ...") call? Quote Link to comment Share on other sites More sharing options...
WolfRage Posted March 8, 2009 Share Posted March 8, 2009 <?php echo '<meta http-equiv="refresh" content=.01; url='.$location.'" />'; ?> Quote Link to comment Share on other sites More sharing options...
corbin Posted March 8, 2009 Share Posted March 8, 2009 If you know the path to the 404 page, you could just readfile() it or include it. Quote Link to comment Share on other sites More sharing options...
atomicrabbit Posted March 8, 2009 Author Share Posted March 8, 2009 If you know the path to the 404 page you could just ... include it. Ahhhhhhhhhhhhh i see the light now... why didn't I think of that... thanks corbin! Quote Link to comment Share on other sites More sharing options...
corbin Posted March 8, 2009 Share Posted March 8, 2009 ;p 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.