Be a Supporter!

Php: .htaccess Http Errors

  • 772 Views
  • 2 Replies
New Topic Respond to this Topic
ZiggyZack99
ZiggyZack99
  • Member since: Apr. 15, 2007
  • Offline.
Forum Stats
Member
Level 15
Melancholy
Php: .htaccess Http Errors 2008-08-09 13:01:01 Reply

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

polym
polym
  • Member since: Oct. 2, 2007
  • Offline.
Forum Stats
Member
Level 14
Audiophile
Response to Php: .htaccess Http Errors 2008-08-09 13:03:12 Reply

All of these could be found in the documentation or by self-discovery. There's no need for idiots like you to rehash the information in a dumber format...

DearonElensar
DearonElensar
  • Member since: Jun. 10, 2002
  • Offline.
Forum Stats
Member
Level 18
Blank Slate
Response to Php: .htaccess Http Errors 2008-08-09 15:25:33 Reply

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