Jump to content
Sign in to follow this  
hobbzilla

[Contribution] Custom HTTP Error Pages

Recommended Posts

You need to look at the .htacess file for v1.2

 

don't include the http://www.domain.com... etc in the ErrorDocument directive

 

like this:

ErrorDocument 400 /catalog/http_error.php?error_id=400

 

That should work.. (at least it does for me.. when I had the full url listed in the .htaccess, I got the same problem you have.

Share this post


Link to post
Share on other sites

I seem to be getting the same prob as gdfwilliams.

In the .htaccess file i have included the whole domain. I have tried without it but the script won't work.

I dont have a catalog folder, the OSC files is running from the root directory (www)

Other than these prob this script is great!

Share this post


Link to post
Share on other sites

Instead of

ErrorDocument 400 /catalog/http_error.php?error_id=400

have you tried

ErrorDocument 400 /http_error.php?error_id=400

(assuming that the http_error.php is in your root directory)


... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Share this post


Link to post
Share on other sites

Thanks, the problem was the slash :D

I didnt add it :roll:

 

Im having troubles with the log. i have a error saying

Warning: error_log: Unable to write to /var/log/www/tep/http_error.log in /home/mdaustra/public_html/http_error.php on line 42

 

what do i do?

Share this post


Link to post
Share on other sites

Unfortunately, I forgot (-duh) to add these important lines:

 

**NOTE**

 

Don't forget to chmod 777 to your log file!! Otherwise apache won't be able to write to it! (it would be a good idea to not leave your logs & etc in a web accessible directory.. If you must.. put an .htaccess file on the folder that the logs are contained in (or anything else that needs to have 777 access (read-write-execute).

 

Let me know if you need any more help! I'm glad a handfull of you have displayed your appreciation. It is a very simple contrib.. but rather useful if I don't say so myself. I was suprised that something like this hadn't already been submitted!

Share this post


Link to post
Share on other sites

Great contribution,

 

I have one question,

How can i make this contribution also work for other directory's?

I get a warning message by e-mail when a visitor look for something is a different directory but the visitor him self isn't getting to see the error page only if the error response from the catalog directory?

 

Marcel

Share this post


Link to post
Share on other sites

Marcel;

 

Do you have the .htaccess file with the error defines in your document root or in your catalog directory? It must be in the document root to cover all areas.

 

(Remember, .htaccess controls everything in the directory it is in and all others below it, unless another .htaccess file in a directory below it changes something in the higher level file)


... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Share this post


Link to post
Share on other sites

Been using this mod for the last week and has been proven to be quick good.

I found 1 problem though.

 

When clicking on a banner, manufacturer website or anything that uses the redirect.php script it will not work, it will detect it as a error thus return the 404 error.

Try clicking on a banner for a example

http://www.minidisc.com.au

Share this post


Link to post
Share on other sites

Well, you've got me stumped. My .htaccess file is in the root web directory (ie where http://farmex.now.tc/index.html resides). It contains just the listing for the custom error pages like so:

ErrorDocument 400 /catalog/http_error.php?error_id=400

ErrorDocument 401 /catalog/http_error.php?error_id=401

ErrorDocument 403 /catalog/http_error.php?error_id=403

etc...

As you can see above, the custom error file (with the switch statements) is in the catalog directory where the public side of my osC installation resides. The second http_error.php file (with the actual defines for the error messages) is in the language folder for the language that applies.

 

Sefu, the redirect problem I'm not sure about, but my manufacturer links look like this

http://farmex.now.tc/catalog/redirect.php?action=manufacturer&manufacturers_id=18

whereas yours look like this

http://www.minidisc.com.au/redirect.php/action/manufacturer/manufacturers_id/7

which makes it look like you have search engine safe URLs turned on. I'm not sure if this would cause the problem or not, but all of my redirects work fine. :?


... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Share this post


Link to post
Share on other sites

sefu,

 

I could be wrong.. but have you attempted to turn off your search engine friendly urls? If turning that off makes the links work correctly, then you will have to modify the banner code to not use search engine safe urls.

Share this post


Link to post
Share on other sites

Sorry, Marcel, I didn't read your question well. I would say yes, it is because you've made full URLs instead of the path reference like I showed.


... if you want to REALLY see something that doesn't set up right out of the box without some tweaking,

try being a Foster Parent!

Share this post


Link to post
Share on other sites
sefu,

 

I could be wrong.. but have you attempted to turn off your search engine friendly urls?  If turning that off makes the links work correctly, then you will have to modify the banner code to not use search engine safe urls.

I have turned them off with no luck. could it be something wrong in the redirect.php script? I dont think i ever modifed it before?

Share this post


Link to post
Share on other sites

Nevermind, my spupidity :roll:

Somehow, someway the redirect.php was deleted from the server. I should of checked before posting.

thanks for your help anyway :)

Share this post


Link to post
Share on other sites
Hi,

I am installing your HTTP error customization, and I have it working, except for the logging and e-mailing...

 

I do not follow your instructions on the .sql and .log files...  (or doing it manually in the catalog/http_error.php file)  could you please clarify?

 

I go to myphpadmin and run the .sql file, right?  what about the log file?  what do I do with that?

 

Thanks

 

Yes, you can run the sql file through phpmyadmin. There are plenty of good resources out there on mySQL and how to use it. Search google.

 

The log file simply needs to be moved somewhere in your hosting space. I would recommend log files NOT be placed in a public directory where anyone could might obtain access. Although if you are on a shared hosting plan, that might be the only directory available, in which case take appropriate measures against unwanted snooping (i.e. password protect directory, etc.)

 

This script assumes that the log file is there and writable by the web server process. usually a chmod 777 is needed on the log file.

 

As far as manually adjusting the script, in lieu of running the sql file, simply edit the http_error.php file.

 

If you want the file to e-mail you or save as a log without setting up the admin portion, simply remove the if {} statement checks for your desired functionality.

 

ie.

 

// Save the HTTP Error Report to disk

 if (STORE_HTTP_ERROR == 'true') {

   error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ',' . $HTTP_GET_VARS['error_id'] . ',' . HTTP_SERVER . $REQUEST_URI . ',' . $REMOTE_ADDR . ',' . $HTTP_USER_AGENT . ',' . $HTTP_REFERER . "n", 3, STORE_HTTP_ERROR_LOG);

 }

 

Becomes:

 

// Save the HTTP Error Report to disk

   error_log(strftime(STORE_PARSE_DATE_TIME_FORMAT) . ',' . $HTTP_GET_VARS['error_id'] . ',' . HTTP_SERVER . $REQUEST_URI . ',' . $REMOTE_ADDR . ',' . $HTTP_USER_AGENT . ',' . $HTTP_REFERER . "n", 3, /var/log/www/tep/http_error.log);

 

This add-on assumes that you have your mail configured correctly (if order receipts & newsletters send correctly, this will work too!).

 

The only thing of note is that if you remove the if{} statement for the log output as shown above, you must also change STORE_HTTP_ERROR_LOG to a valid pathname for the log file - which already resides there and is writable. See above example.

Share this post


Link to post
Share on other sites

I have been having some strange issues with this mod. I just recently upgraded to MS1 daily CVS so I'm not sure if there might be some new tweaks that are causing a problem.

 

Basically, I can go my website and surf it completely fine. (In other words, I do not get any HTTP_Error pages. However, I get a ton of emails that appear to be generated from the http_error page. It is almost as if the http_error.php file is getting run through the scripting engine by accident anytime any customer views a normal page. Has anyone else had this problem?

 

Here's my htacces file in case it helps:

# $Id: .htaccess,v 1.1 2002/07/21 23:41:41 hpdl Exp $

#

# This is used with Apache WebServers

#

# The following makes adjustments to the SSL protocol for Internet

# Explorer browsers

#

# For this to work, you must include the parameter 'Limit' to the

# AllowOverride configuration

#

# Example:

#

#<Directory "/usr/local/apache/htdocs">

#  AllowOverride Limit

#</Directory>

#

# 'All' with also work. (This configuration is in your

# apache/conf/httpd.conf file)



<IfModule mod_setenvif.c>

 <IfDefine SSL>

   SetEnvIf User-Agent ".*MSIE.*" 

            nokeepalive ssl-unclean-shutdown 

            downgrade-1.0 force-response-1.0

 </IfDefine>

</IfModule>



# -FrontPage-



IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*



<Limit GET POST>

order deny,allow

deny from all

allow from all

</Limit>

<Limit PUT DELETE>

order deny,allow

deny from all

</Limit>

AuthName www.hipoparts.com

AuthUserFile /www/hipoparts/_vti_pvt/service.pwd

AuthGroupFile /www/hipoparts/_vti_pvt/service.grp



ErrorDocument 400 http://www.hipoparts.com/http_error.php?error_id=400

ErrorDocument 401 http://www.hipoparts.com/http_error.php?error_id=401

ErrorDocument 403 http://www.hipoparts.com/http_error.php?error_id=403

ErrorDocument 404 http://www.hipoparts.com/http_error.php?error_id=404

ErrorDocument 405 http://www.hipoparts.com/http_error.php?error_id=405

ErrorDocument 408 http://www.hipoparts.com/http_error.php?error_id=408

ErrorDocument 415 http://www.hipoparts.com/http_error.php?error_id=415

ErrorDocument 500 http://www.hipoparts.com/http_error.php?error_id=500

ErrorDocument 501 http://www.hipoparts.com/http_error.php?error_id=501

ErrorDocument 502 http://www.hipoparts.com/http_error.php?error_id=502

ErrorDocument 503 http://www.hipoparts.com/http_error.php?error_id=503

ErrorDocument 505 http://www.hipoparts.com/http_error.php?error_id=505

ErrorDocument 504 http://www.hipoparts.com/http_error.php?error_id=504

 

Anyone have any ideas?

Share this post


Link to post
Share on other sites

Well, I don't see why this script would be executed each time a non-error producing page was served.. Let's do this: verify by making changes to the e-mail that is sent to you (in includes/languages/LANGUAGE/http_error): where you

define('EMAIL_BODY',...

 

Just add something different in there to distiguish itself.. and then visit a known working url and see if you get an error report e-mailed to you with the updates you just made to the language file. I could only guess then that something is not configured correctly with Apache (your .htaccess file looks fine)..

 

I have never heard of this but I don't see why it couldn't be possible:

Perhaps there is an inclusion of an html file that is mis-named or an image that is generating a 404 and so it loads that script in a frame or an <span> or something.. I dunno.. I would just find a page that loads but consistently e-mails you an error and dissect that page line by line for every image or file include.

 

HTH.

Share this post


Link to post
Share on other sites

yep.... I'm pretty sure it is being generated using the language file.

 

Attached is an example email:

 

Date: Tue, 22 Apr 2003 14:59:05 -0600

From: "HiPoParts" <Sales@hipoparts.com>          

To: "HiPoParts Error" <web@hipoparts.com>

Subject: A Customer Received an HTTP Error  

 

------------------------------------------------------ Site: http://www.hipoparts.com/. Error Code: 404 - Not Found Occurred: 04/22/2003 14:59:04 Requested URL: http://www.hipoparts.com//http_error.php?error_id=404 User Address: 81.86.145.4 User Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0..3705) Referer: http://www.hipoparts.com/product_featured....?products_id=35 ------------------------------------------------------

Share this post


Link to post
Share on other sites

wheh! I thought I would never figure this out....

 

It turns out that the http_error.php script was running exactly as it should when a file is not found. The 404 error described was pretty good too.

 

It actually took me using a packet sniffer on my lan to troubleshoot this and see what the HTTP packets were doing....

Here's why I wasn't seeing the error....

 

I had modified my stylesheet to specify a background graphic...

body

{

background-image: url(images/flagbk.gif);

MARGIN:0; MARGIN-LEFT:0;MARGIN-TOP:0;

BACKGROUND-COLOR: #FFFFFF;

}

 

while this is not normally a problem, since I am using thema stylesheets, the stylesheet is not in the same root folder as my catalog....

so when my web browser was processing the stylesheet for "body" it was looking for the graphic:

www.hipoparts.com/includes/classes/thema/1/images/flagbk.gif

instead of:

www.hipoparts.com/images/flagbk.gif

 

I wasn't seeing the lack of the image, because I had also declared the "body" style in the header.php file.

 

As soon as I removed the graphic file reference from my stylesheet, the errors stopped.

 

Anyway... probably a long explanation for such a silly mistake, but I figured I would document my experience in case anyone else is using http_error and thema stylesheets.

Share this post


Link to post
Share on other sites

LoL.... i thought the forbidden page's did not work cous i banished a person (Via the same htacces file in the root of the site) that orderd for over 50.000.000? and try'ed the ban on myselve 2 then i got an 403 error on the 403 page... hmmzzz.... some1 found a sollution for this???

Share this post


Link to post
Share on other sites
i got an 403 error on the 403 page... hmmzzz.... some1 found a sollution for this???

Well if you are banning someone and they would then be getting a forbidden error then they obviously would be getting a forbidden error when trying to access the http_error.php page. The one thing I would suggest if you want them to see a personalized 403 error page is to make sure that the http_error.php page is not in the forbidden realm for that user (or perhaps on an entirely diffent namespace)

 

HTH

Share this post


Link to post
Share on other sites
P.S.

Give it a try through your browser. Go to

http://farmex.now.tc/stuff

 

Hey man, your log file is not writable, go to your link in the quote and look at the very top of the page to see the write error.


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites
Marcel;

Do you have the .htaccess file with the error defines in your document root or in your catalog directory? It must be in the document root to cover all areas.

 

Not True!

 

You can have the .htaccess file in ANY directory. I have a forum at http://www.popthetop.com/forum and the store at http://www.popthetop.com/catalog

 

I have a separate .htaccess file in both the forum AND the catalog directories. Each run their own things and works great.

 

I then have another .htaccess file in my root to do other things for the rest of the site.


L8r,

PopTheTop

 

Published osC Contributions:

- eCheck Payment Module v3.1

- Reviews in Product Display v2.0

- Fancier Invoice & Packingslip v6.1

- Admin Notes / Customer Notes v2.2

- Customer Zip & State Validation v2.2

- Search Box with Dropdown Category Menu v1.0

 

Pop your camper's top today!

It's a popup thing...

You wouldn't understand

Share this post


Link to post
Share on other sites
Not True!

 

You can have the .htaccess file in ANY directory. I have a forum at http://www.popthetop.com/forum and the store at http://www.popthetop.com/catalog

 

I have a separate .htaccess file in both the forum AND the catalog directories. Each run their own things and works great.

 

I then have another .htaccess file in my root to do other things for the rest of the site.

 

Yes you can put a .htaccess file in any directory you want and the rules will be executed for that directory and subdirectories, unless another .htaccess file existes for the subdirectories so on and so forth.

 

That wasn't the point of his statement. It was specifically for specifying the error document.

Edited by hobbzilla

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×