00:00
00:00

Our goal is for Newgrounds to be ad free for everyone! Become a Supporter today and help make this dream a reality!

Php: .htaccess Http Errors

1,230 Views | 1 Reply
New Topic Respond to this Topic

Php: .htaccess Http Errors 2008-08-09 13:01:01


If you've noticed, you don't see the sexy FF 404 Not Found or the tacky IE 404 Not Found page when you go to http://podtube.co.cc/nonexistantjunkthat fatchixwithgaydadsluvrlulz12.html. Instead, you see a page saying Something Bad, 404!. Now, if you wish to make a solution, try this shiz: Make a .htaccess file in your web server's root dir:

ErrorDocument 404 /error.php?id=404
ErrorDocument 403 /error.php?id=403

This tells the server to redirect all requests for nonexistant pages and pages you are denied access to (404 nd 403, respectively) to redirect to error.php in the root dir, with a GET parameter of id, specifying the error code. Now, all that remains left to do is error.php:

<? if ($_GET[id] = 404) { ?>
NOT FINDED
<? } elseif ($_GET[id] = 403) { ?>
ACCESS DENIED
<? } else { ?>
SOMETHING ELSE BAD
<? } ?>

Obviously, there is much more possible than just those two things. You could extend it to the database, format it, or even make it send an email to the webmaster using mail(). Experiment!


n/a

Response to Php: .htaccess Http Errors 2008-08-09 15:25:33


Yeah, this is so basic that it doesn't even deserve to be listed :/ (in other words, a 5 second search will give you a better tutorial)


BBS Signature