The Little Guy Posted January 28, 2009 Share Posted January 28, 2009 I want to display a 403 error page, but it isn't working. I don't wanna make a 403 page, I just want to use the current one. This doesn't display anything: <?php include '../../db.php'; if($_SESSION['logged']){ // Will do something soon }else{ header("HTTP/1.1 403 Forbidden"); } ?> Quote Link to comment Share on other sites More sharing options...
corbin Posted January 28, 2009 Share Posted January 28, 2009 That header just means to tell the client that they have been denied. It doesn't do anything in the sense of displaying your other error page. You will have to either redirect the client, or show the error page you want to show. Quote Link to comment Share on other sites More sharing options...
Prismatic Posted January 28, 2009 Share Posted January 28, 2009 I want to display a 403 error page, but it isn't working. I don't wanna make a 403 page, I just want to use the current one. This doesn't display anything: <?php include '../../db.php'; if($_SESSION['logged']){ // Will do something soon }else{ header("HTTP/1.1 403 Forbidden"); } ?> <?php include '../../db.php'; if($_SESSION['logged']){ // Will do something soon }else{ die("HTTP/1.1 403 Forbidden"); } ?> Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 28, 2009 Author Share Posted January 28, 2009 Yeah that I know... I just cant remember how to display Apache's default 403 page (I thought that it was possible). Quote Link to comment Share on other sites More sharing options...
corbin Posted January 28, 2009 Share Posted January 28, 2009 You can't just magically display a page. You have to either take some steps to display it, or you can redirect somewhere else. die("HTTP/1.1 403 Forbidden"); That will not send out a header. It will literally say that. Quote Link to comment Share on other sites More sharing options...
printf Posted January 28, 2009 Share Posted January 28, 2009 header ( 'Status: 403 Forbidden' ); Apache or any server that follows the HTTP RFC stanard will replace the default status with the one included in the header. Apache as well Sambar, IIS will serve up the default Forbidden document. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 28, 2009 Author Share Posted January 28, 2009 and those steps would be... Edit: @printf: that didn't make a difference Quote Link to comment Share on other sites More sharing options...
printf Posted January 28, 2009 Share Posted January 28, 2009 Sorry it doesn't work for you, I just tried it on my Apache server and it worked, but it didn't work for IIS. I mean it does send the 403 Forbidden Status, but it doesn't serve the default Forg\bidden page. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 28, 2009 Author Share Posted January 28, 2009 nope see: http://yougotdat.publicsize.com/f/js/sp.php Quote Link to comment Share on other sites More sharing options...
DarkWater Posted January 28, 2009 Share Posted January 28, 2009 nope see: http://yougotdat.publicsize.com/f/js/sp.php Well, it's certainly sending the header. You can probably just include the default 303 page... Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted January 28, 2009 Author Share Posted January 28, 2009 So how do I include Apache's default 403? I don't want to make one. Quote Link to comment Share on other sites More sharing options...
corbin Posted January 28, 2009 Share Posted January 28, 2009 You would have to know the path to it. Then you could just do readfile() or something. Quote Link to comment Share on other sites More sharing options...
gevans Posted January 28, 2009 Share Posted January 28, 2009 Just make a pretend page, <?php function runForbidden() { header('HTTP/1.1 403 Forbidden'); echo "<html> <head> <title>403 Forbidden</title> </head> <body> <p>Access is forbidden.</p> </body> </html>"; die(); } runForbidden(); 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.