Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-22-2004, 01:15 PM   #1
Seb From Holland
Confirmed User
 
Join Date: May 2002
Location: The Netherlands
Posts: 2,747
GFY Tutorial: Error Pages In PHP!

Hey GFY,

Here's a little contribution from me to the board. I know many of you use errorpages on your servers and now that the web has become one dynamic place, it's a smart thing to update those static old pages to nice dynamic ones. The example I'm going to show you is really simple and anyone who has little knowledge of HTML/PHP can do it.

Most of the times, your .htaccess file which contains links to the error documents on the server looks like this:

ErrorDocument 400 http://www.domain.com/errors/400.html
ErrorDocument 401 http://www.domain.com/errors/401.html
ErrorDocument 403 http://www.domain.com/errors/403.html
ErrorDocument 404 http://www.domain.com/errors/404.html
ErrorDocument 405 http://www.domain.com/errors/405.html
ErrorDocument 410 http://www.domain.com/errors/410.html
ErrorDocument 500 http://www.domain.com/errors/500.html

Which is perfect in it's way, apart from the fact that they are links to several static pages.

Let's say we want to have just one error page covering all errors (there are somewhat 22 client and server errors to my knowledge). How do you do it? Simple:


1.) Create a new .php document, say error.php or any other name if you like.

2.) Make an if-statement or a case-statement in which you define all errors. So if the error.php?id=404, the if statement should be able to recognize it and add the value "page not found" to the doc.ument. Here's a little if-statement I made with different errors:

<center></center>

3.) Place this bit of code on top of all your HTML, even before the <html> opening.

4.) Create a page of your preference. Perhaps you want the error page in the same style as your Website, thats up to you. In this example I made a very simple page, just displaying the error. Of course, you can do with it whatever you like. Here's my HTML setup:

<center></center>

Don't mind what's in the title tag. That's not part of the error code.

So now you have created a page that contains every error. You can throw away you 15 old static errorpages. No use for them anymore. The only thing you have to do now is to adjust your .htaccess file. Make it look like this:

ErrorDocument 400 http://www.domain.com/error.php?id=400
ErrorDocument 401 http://www.domain.com/error.php?id=401
ErrorDocument 403 http://www.domain.com/error.php?id=403
ErrorDocument 404 http://www.domain.com/error.php?id=404
ErrorDocument 405 http://www.domain.com/error.php?id=405
ErrorDocument 410 http://www.domain.com/error.php?id=410
ErrorDocument 500 http://www.domain.com/error.php?id=500

Download the codes here:
http://www.signaturetracker.com/gfy/error.txt (error.php code)
http://www.signaturetracker.com/gfy/htaccess.txt (.htacces code)

Enjoy!

Seb.

(Don't forget to upload your new or adjusted .htaccess in ASCII format.)
Seb From Holland is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:17 PM   #2
Veterans Day
Confirmed User
 
Join Date: Jul 2003
Location: The Windy City
Posts: 8,403
Veterans Day is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:22 PM   #3
- Jesus Christ -
Confirmed User
 
Industry Role:
Join Date: Mar 2003
Location: ::::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: ::::::||||||||||||:::::: :::::::::::||::::::::::: :::::::::::||::::::::::: ::::::::::::::::::::::::
Posts: 7,197
Quote:
Originally posted by Seb From Holland
3.) Place this bit of code on top of all your HTML

WTF!


THis is the dumbest tutorial I have ever read....


Why would want to parse a PHP code error script when apache has it built in... you could have at least shown people how to automatically append thae header to all thier pages...

Even then this is still pointless.

Oh yea... also if you just place PHP code at the top of an HTML file it will nopt be parsed unless you set apache to parse html files as php.
__________________

Amen
- Jesus Christ - is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:27 PM   #4
Seb From Holland
Confirmed User
 
Join Date: May 2002
Location: The Netherlands
Posts: 2,747
Thanks for your kind reply Jesus Christ, you remind me again why I have you on ignore.

Obviously you have failed to understand my tutorial, otherwise you wouldn't have corrected me on the fact that .html doesn't parse php code, of course it doesn't.
Seb From Holland is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:29 PM   #5
zentz
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Posts: 8,053
__________________
Programs that owe me money ---- Epassporte.com ~ $2700 | Protraffic.com ~ $2600 | XonDemand.com ~ $3000

Email: [email protected]
zentz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:29 PM   #6
- Jesus Christ -
Confirmed User
 
Industry Role:
Join Date: Mar 2003
Location: ::::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: ::::::||||||||||||:::::: :::::::::::||::::::::::: :::::::::::||::::::::::: ::::::::::::::::::::::::
Posts: 7,197
then what the fuck is "Place this bit of code on top of all your HTML, even before the opening." refering too..... Seeing as its right after a picture of PHP code.


Either way this is totally pointless...
__________________

Amen
- Jesus Christ - is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:31 PM   #7
Poo-Chee
So Fucking Banned
 
Join Date: Sep 2003
Location: Rotterdam
Posts: 3,560
Quote:
Originally posted by Seb From Holland
Thanks for your kind reply Jesus Christ, you remind me again why I have you on ignore.

Obviously you have failed to understand my tutorial, otherwise you wouldn't have corrected me on the fact that .html doesn't parse php code, of course it doesn't.
Seb from Holland is 1337
Poo-Chee is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:31 PM   #8
Babaganoosh
♥♥♥ Likes Hugs ♥♥♥
 
Babaganoosh's Avatar
 
Industry Role:
Join Date: Nov 2001
Location: /home
Posts: 15,841
Actually, JC is kind of correct. Why do this instead of letting Apache handle it? This seems like a really long, complicated way to do what should be a very easy task.
__________________
I like pie.
Babaganoosh is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:38 PM   #9
Seb From Holland
Confirmed User
 
Join Date: May 2002
Location: The Netherlands
Posts: 2,747
Sure if you know this so well, why don't you spend a little time writing your own tutorial. I'm sure we'd all profit from it. It's so easy to bash things isn't it. Too bad that when you spend time and effort into something just to help fellow webmasters out, that almost the first person calling it the dumbest thing ever.
Seb From Holland is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-22-2004, 01:40 PM   #10
- Jesus Christ -
Confirmed User
 
Industry Role:
Join Date: Mar 2003
Location: ::::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: :::::::::::||::::::::::: ::::::||||||||||||:::::: :::::::::::||::::::::::: :::::::::::||::::::::::: ::::::::::::::::::::::::
Posts: 7,197
Quote:
Originally posted by Seb From Holland
Sure if you know this so well, why don't you spend a little time writing your own tutorial. I'm sure we'd all profit from it. It's so easy to bash things isn't it. Too bad that when you spend time and effort into something just to help fellow webmasters out, that almost the first person calling it the dumbest thing ever.
note other SEOS coming in and getting a little pissed I posted it?

http://www.gofuckyourself.com/showth...hreadid=238012

I would advise agasint bumping it.... but use it.
__________________

Amen
- Jesus Christ - is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.