Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: Deprecated on September 02, 2008, 04:15:47 AM

Title: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 04:15:47 AM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1363)

Obsolete.
Title: Re: Add an Apache Error Handler to SMF
Post by: Nathaniel on September 02, 2008, 04:35:22 AM
Very nice mod. :)

Downloaded and installed for SMF 2 Beta with no hitches. ;D

I had previously done this by using a host error page to redirect the user to a custom action within SMF, this makes it much easier.
Title: Re: Add an Apache Error Handler to SMF
Post by: Charles Hill on September 02, 2008, 06:21:47 AM
You should be aware that this is totally incompatible with the Pretty URLs mod.  I just tested it on my dev site.  Had to type out the entire URL to uninstall the package.
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 06:56:40 AM
Readme.txt from the package:

Add an Apache Error Handler to SMF


Version: 1.0 Date: 2008-08-30
Compatibility: SMF 1.1.5, SMF 2.0 Beta 3.1 or later

This modification adds to SMF the capability to intercept all Apache errors such as 'Error 404 - Not Found' and the like, and displays an error message to your members using your familiar forum format. It also adds error entries to SMF's error log so that you can see and investigate the errors.

There is an important matter that every hosting customer should understand. Hosting services provide default error pages if the customer does not supply their own. For example, my SMF test forum domain has the word 'dog' in its domain name, I guess because I'm fond of the critters. Without my custom error page I get a default hosting service error handler that they use for parked domains. They must have sensed the word 'dog' in my domain name because they serve up a page of suggestions for other domains that might have what the site visitor is looking for. In my case the Error 404 page has suggestions for dog food, vetenarians, dog informational sites, etc. Ask yourself this question: Are you willing to take the chance that your hosting service will send your forum members to competing services including competing forums whenever there is a site error?
FeaturesNote: The modification will work only on servers with Apache installed.
Screen shot

(http://img205.imageshack.us/img205/4769/error404pp9.jpg)
Installation

Please back up your index.php and .htaccess files before beginning the installation. Automatic deinstallation almost always succeeds but it never harms to be prepared for the worst.

The modification automatically adds directives to your .htaccess file if one is present, or creates a new .htaccess file otherwise. Any existing .htaccess file is renamed .htaccess~ for a backup after its contents have been added to the new .htaccess file. Uninstalling the modification restores your old .htaccess file if one was present, or removes the modification's .htaccess file otherwise. If you delete the backup file the modification will attempt to remove its directives from whatever .htaccess file it finds, or does nothing to the file if the modification's directives cannot be safely removed.

The .htaccess file is installed in your board directory whether it is '/' or '/forum/' or whatever your called it. If your forum is installed in e.g. '/forum/' and you would like your SMF to handle errors from the entire domain (such as including your portal) you can copy the .htaccess file to your '/' folder. Uninstallation will not remove any copied file so you will have to manually delete it if you uninstall the modification.

Note 1: If you already have a 'RewriteEngine on' directive, the modification still adds its own. Multiple instances of the directive will harm nothing, and your directive will still be there if you uninstall the modification.

Note 2: Please understand that Error 500 Internal Server Error is internally generated by Apache when it is unable to handle a request for any reason. This occurs before your error handler can be called so it is unlikely that you will ever see an Error 500 display or log entries. It is not possible to intercept Error 500 under normal circumstances so this is not a failing of the modification.
Uninstallation

Use SMF's package installer to remove the modification.

Note: If desired, the included UpdateHtaccess.php file can be run stand-alone in your board directory to modify or demodify your .htaccess file. Use 'UpdateHtaccess.php' to install the .htaccess file changes. Use 'UpdateHtaccess.php?uninstall' to remove the .htaccess file changes. Or alternately, you can just manually edit or delete your .htaccess fie.
Support

You may get support or submit questions and comments in the modification's support thread at the SMF site.[/hr][/hr][/hr][/hr][/hr]
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 07:13:17 AM
@LHVWB Thanks for the comments LH! I had been running a separate error handler script where I had done a quick hack, viewing HTML source on my forum index and cut 'n pasted enough HTML to make the top part look like SMF. I've been running custom error handler scripts on my non-forum websites for a couple years, and have found the error logs to be quite handy for debugging pesky little site inconsistencies. I have began running SMF forums only the last couple months but almost from the beginning when I realized I could hack my SMF and install any feature I was willing to take the time to code up, I realized that it was only a matter of time before I added custom error handlers, but it was only by finishing my earlier modification packages that I gained sufficient knowledge to tackle this mod package. I believe that my other mod packages were nice, but before now I can't really say that any of my mods couldn't be lived without. Apache Error Handler is the first mod I've written that I would put in the "can't live without" category.

@Charles, yes, of course. The Pretty Urls mod is incompatible with my Apache Error Handler mod, as are other web servers that don't run Apache. I think "totally" might be overstating the case however. I think a manual edit of the .htaccess file should allow my error handler to be called by Apache through the .htaccess and into SMF to land at the error script. It will require somebody to figure out what the Pretty Urls address of the error handler is, then an edit of the .htaccess to convert the error handler redirections to be compatible. If there is no compatible way to address the error handlers then we'll have to mod the mod and get PU to work with my mod. It doesn't sound too hard. My test SMF imploded when I installed PU and I made the decision that the URLs didn't make that much difference with search engines, so I gave up. Perhaps you or somebody with PU already working could figure it out and let me know if there's anything I should do to my mod to make the two work together. I hope it's just a matter of figuring out what PU needs to make a working path to the error handler.
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 07:24:25 AM
Everybody should realize the power behind having Apache errors appear in your SMF log will in many cases open up a can of worms, revealing errors you wouldn't have even been aware of before. For example, most browsers ask for a favicon.ico file, the little graphic that appears in your browser's URL bar and bookmarks. You never realized before that all these 404 file not found transactions were going on because browsers are designed to not report them to site visitors, and you didn't have any error log before. There was no way you could have known they were there, although now all must realize that most SMF sites get hundreds, or depending on forum size thousands of 404 not founds from the missing favicon.ico alone.

So the first thing right off everybody will probably want to either install my Add Favicon.ico Support (http://custom.simplemachines.org/mods/index.php?mod=1329) modification package to their SMF, or at least get the readme.txt file and go to one of the instant favicon.ico sites and throw together a favicon and put it in your root directory. The mod adds a few lines to SMF's HEAD section of your HTML to help some reluctant browsers find the favicon file, but that is unnecessary if you just want to get rid of the errors because any browser that asks for the favicon is going to know where to find it. Put the file there and you will eradicate the favicon 404 not found errors. Or install the mod and embrace the favicons. :) I rather like them and consider the favicons to be a nice little professional touch to finish off a nice SMF forum site.

All who are interested in Add Favicon.ico Support (http://custom.simplemachines.org/mods/index.php?mod=1329) are asked to please direct any favicon questions to the mod's support thread (http://www.simplemachines.org/community/index.php?topic=255428.0). Please do not take the Add Apache Error Handler discussion thread off topic with favicon questions. Thank you. :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 07:43:03 AM
There is another thing I should mention right off, that perhaps there is one small misleading statement related to this mod package. Although the modification is designed to intercept the 500 Internal Server Error messages, Apache is not designed to send the 500 errors to custom error handlers. The 500 error in some cases is even caused by errors in your .htaccess file, so whan Apache decides that it cannot handle the .htaccess file it throws the file out the window and uses it's own error message instead of calling your error handler. But... My modification is compatible with accepting and reporting 500 error messages if Apache ever decides to send them to custom error handlers. :)

From the modification's readme.txt file:

QuotePlease understand that Error 500 Internal Server Error is internally generated by Apache when it is unable to handle a request for any reason. This occurs before your error handler can be called so it is unlikely that you will ever see an Error 500 display or log entries. It is not possible to intercept Error 500 under normal circumstances so this is not a failing of the modification.

That also brings up another interesting point. I suspect that the overwhelming majority of SMF forums run on Apache installed on top of Linux as the server's OS and Internet server. However, it is possible to install SMF on a Microsoft Windows server. While those servers do report 404 errors and the other standard HTTP error conditions, they do not as far as I know use .htaccess files, so this modification will not work in those situations. It is possible that there is some equivalent configuration file for Microsoft, but that is outside my knowledge. Bill Gates has so much money, so as far as I'm concerned he can fix it on his end! ;)

Check your hosting account or on SMF go to Admin -> Main -> Support and Credits -> and look at your Support Information report. It should have a line "Server Version: Apache ..." if you are running Apache on your server. If so you are good to go. If not, head back to SMF's mod shop and pick a different modification. :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Charles Hill on September 02, 2008, 03:52:00 PM
I have weighed the usefulness of Pretty URLs mod vs this mod.  I have chosen this mod.  I had to add a little code to auto-redirect users from old "pretty" URLs to their un-pretty counterparts, but I like this mod :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 04:28:34 PM
Thank you Charles! I'm very flattered. :)

I expect within a short time this mod will overtake all my other mods in total downloads and will become my most successful and useful modification package to date. The other mods were nice but this mod serves an important function. I think practically ever SMF forum should have this mod, the only exceptions being those where the admins don't really care about errors as long as the site plays okay.

One nice thing is that the code is not at all complex. ApacheError.php and ApacheError.template.php are straightforward and simple. The trickiest part was coding the helper script that modifies and unmodifies your .htaccess file. I made it as smart as I could so that it could do the best possible job in installing, and in particularly removing its changes to .htaccess files.

I'm expecting this mod to be pretty trouble free but I'll be here to handle any support requests. I'm pretty pleased with this one! :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Charles Hill on September 02, 2008, 04:36:06 PM
Yea it very easy to make the changes I wanted.  I've already found and corrected several missing file errors :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 04:48:25 PM
Exactly!!! One thing that experienced SMF administrators realize is that their error log is their best friend. It tells you if your forum is healthy or buggy. The only errors I can think of that you would expect to find in a healthy forum are the "Password incorrect" errors. People are idiots and often mistype their passwords. Ask me how I know. ;)
Title: Re: Add an Apache Error Handler to SMF
Post by: Charles Hill on September 02, 2008, 04:49:27 PM
Hey now... I type my password wrong sometimes too :)
Title: Re: Add an Apache Error Handler to SMF
Post by: mashby on September 02, 2008, 05:03:37 PM
Extremely cool mod. It's picking up 403s (I had to ban an IP address at the cpanel level as it was doing some strange stuff on my forum and continues to do so). Now I can see how often this IP tries to access my site. I now know it's many times today. Didn't know that before! Thank you for developing this one.
Title: Re: Add an Apache Error Handler to SMF
Post by: Charles Hill on September 02, 2008, 05:51:03 PM
Only change I am considering making is making a separate error page or perhaps just an additional filter to filter out the extra errors... so that I can quickly find normal site errors.
Title: Re: Add an Apache Error Handler to SMF
Post by: kizer on September 02, 2008, 06:16:12 PM
I'd be interested in hearing how that filter works.

I don't mind knowing what my errors are, but if there are several man it can get over whelming trying to fix them all.

Maybe an ignore ***** would be nice.
Title: Re: Add an Apache Error Handler to SMF
Post by: kizer on September 02, 2008, 06:21:42 PM
I know this is probably obivous, but if SMF is in a directory such as /forum its not going to change or report errors from say http://www.mainroot.com right? I'd hate to have to even try and deal with every possible missing file request because some ding dong is looking for dog.html and it doesn't exist or never did on the root of my domain.
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 06:33:39 PM
This modification installs or alters an .htaccess in the same directory as your forum's index.php, e.g. /forum. Apache will use that .htaccess file only for the /forum directory and subdirectories underneath it. Errors from above your /forum directory will be handled by whatever rules exist in higher level .htaccess files or by your hosting service's default error handlers.
Title: Re: Add an Apache Error Handler to SMF
Post by: karlbenson on September 02, 2008, 07:01:58 PM
While this is a very nice mod.

Generally it is often better to redirect to a static html page which uses as little resources as possible.

Having these error build up in your smf error log could depending on the site, could cause some performance issues.
My warning would be to fix any issues immediately/asap as they arise.  Never ignore or just delete.

This is something I've been doing recently, on hack attempts, and such.  Keeping them from getting anywhere near from smf (saving queries and bandwidth) by sending them to a simple noindexed static html page http://www.youposted.com/error.html
As a result I have enjoyed increased performance.

Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 02, 2008, 07:39:21 PM
Well, it has occurred to me that static error pages use less resources, and that having errors caused by a broken SMF being sent to the same broken SMF isn't entirely the best thing to do since it might be too broken to deliver an error page. And also while I haven't tested for this I imagine that if you put SMF into maintenance mode that your error pages will be offline too.

On the other hand my SMF forums run fine with very few errors, and almost all of them are "Password incorrect" errors. And I really like the integration of my error pages into SMF because it makes the whole site nice and consistent. I also like that the logging is all in one place and easily accessible. I really like the way this mod integrates the whole site seamlessly and I'm working on other mods that integrate even more functions into SMF's look and feel. In the end I want every page on the domain to be something served by SMF with no external packages required.

It's a matter of personal preference, and no one viewpoint is any more valid than the other.
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on September 03, 2008, 08:32:54 AM
Nice job mate. :)
Could you add an area, where under your maintenance section in the AP, you would have 404 separate?
eg.
before:
Forum Maintenance
Generate Reports
Forum Error Log
Moderation Log

after:

Forum Maintenance
Generate Reports
404 error log
Forum Error Log
Moderation Log

Or would this be too heavy?

regards
Title: Re: Add an Apache Error Handler to SMF
Post by: Nathaniel on September 03, 2008, 08:34:04 AM
I have to agree with Sabre™, it would be nice to have a separate 404 error log. ;)

Although I think that filters should work....
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 03, 2008, 08:59:00 AM
Th
Quote from: Sabre™ on September 03, 2008, 08:32:54 AM
Nice job mate. :)
Could you add an area, where under your maintenance section in the AP, you would have 404 separate?
eg.
before:
Forum Maintenance
Generate Reports
Forum Error Log
Moderation Log

after:

Forum Maintenance
Generate Reports
404 error log
Forum Error Log
Moderation Log

Or would this be too heavy?

regards

Thanks for the compliment. :)

I don't think you need any work at all to get what you want. In your SMF error log, just look at the error record for the little magnifying glass next to the words "Error 404 - Not found." Click it and it will apply a filter and show you only the 404 errors in your log. Then you can analyze them or mass delete them.

I believe the advanced filters are available only in SMF 2.0. I don't intend to write any code for SMF 1.1.5 to fix new features that it doesn't have. Just upgrade if this is a problem for you. I hear that new Beta 4 is just around the corner! :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on September 03, 2008, 09:09:13 AM
Yeah ok.
I'll wait till SMF 2 is ready for me  lol    >> stable

Anyway for you to make a section to edit what is displayed?
I grew rather fond of my 404 page  lol    but agree that this looks more.......... structured with the forum.
So I would like to add what I have aswell, but would be easy if you had it like your rules section, where you can add the content like a post.

Just an idea for those of us new to the field ;)
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 03, 2008, 09:28:08 AM
I just did some more checking. The error filters work, but they work too well. I just checked some 404s I created myself, and when you use the error filter it finds all the 404 errors but only on that specific URL. This is not a very useful filter because once you know the URL you know where to look to fix it. Getting more of the same error provides no additional utility.

Everybody should understand that this modification does not create or format the error log. It merely uses the existing interface to add errors to SMF's log. The interface allows calling routines (e.g. my error handler) to supply only one alphanumeric string. The string I'm supplying gives the error type (Error 404 - Not Found) plus the URL (e.g. http://www.example.com/smf/forum.php). I don't have any other interface to the logging function, and I'm not going to rewrite the logging code. I could take the URL out to make all the 404 file not found errors filter together, but without the URL the function would be useless!

To sum it up, your request is impossible to deliver without rewriting SMF's logging routines. Sorry! :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 03, 2008, 09:35:34 AM
@Sabre:

I hear what you're saying but I'm not interested in writing logging functions nor am I interested in modifying SMF's existing logging code. Perhaps some young, hungry, up and coming mod author might like to write an advanced logging tool for SMF, but I'm just an old grizzled programmer getting too decrepit to be useful for anything beyond serving as a bad example. ;)

The issue of logging the 404s separately is an SMF logging issue, not an Apache Error Handler issue. I can't fix that from my side of the fence, and I'm not going to climb over the fence! :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on September 03, 2008, 09:42:05 AM
Quote from: Deprecated on September 03, 2008, 09:35:34 AM
..........I'm just an old grizzled programmer getting too decrepit to be useful for anything beyond serving as a bad example. ;)
lol

Quote from: Deprecated on September 03, 2008, 09:35:34 AM
The issue of logging the 404s separately is an SMF logging issue, not an Apache Error Handler issue. I can't fix that from my side of the fence, and I'm not going to climb over the fence! :)
This is in response to post 19 or 22?
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 03, 2008, 09:51:53 AM
Quote from: Sabre™ on September 03, 2008, 09:42:05 AM
Quote from: Deprecated on September 03, 2008, 09:35:34 AM
The issue of logging the 404s separately is an SMF logging issue, not an Apache Error Handler issue. I can't fix that from my side of the fence, and I'm not going to climb over the fence! :)
This is in response to post 19 or 22?

Yes! :D

It's in response to both of them and also to all the questions regarding logging the 404s. That is not part of my error handler modification. The way that SMF logs errors is beyond my control. That is a function of the error logging routines, and I'm not interested in rewriting them. I have only one way to interface to SMF's error logging and that is through SMF's log_error() function. It allows me to pass to it only one thing, the error description that you see in the log, a single alphanumeric string.

The only way you can change that as far as I know is to rewrite SMF's logging routines, and I'm not interested in that job. Perhaps some other aspiring mod package author might take it on and you should post your request in the Mod Requests board.

It is not a deficiency in my Apache Error Handler. It is a deficiency in SMF's logging function. I can't help that. :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on September 03, 2008, 10:01:32 AM
O yep ok.
With post no.22, I have a swf file(animation) I use for my 404, and was suggesting another way to add it, without manually adding it into the template. Like how you add content to a post.
It would make it easier for others, and adds another level of flexibility, usability, and fun to the dreaded 404   lol
Its understandable that you dont feel the need to play with this, it is not a necessity. Im just hoping someone strolls along and adopts the idea.

Thanks once again :)
Title: Re: Add an Apache Error Handler to SMF
Post by: kizer on September 03, 2008, 11:56:18 AM
I haven't installed it as of yet, but is there an off/on switch? I'm asking because "if I do" have errors and I need to fix them which is obvious, but it would be nice not to have 100's of errors simply because it was hard to fix or hard to get to, to fix.
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 03, 2008, 04:35:28 PM
The easiest way to turn it on and off would be to turn your redirection on and off. If you have no other mods that depend on your .htaccess file, you can just temporarily rename your file via FTP. Then change the name back to turn it on.

The mods to SMF actually have nothing to do with the errors. The mods just create the logging for it.
Title: Re: Add an Apache Error Handler to SMF
Post by: Bancherd on September 05, 2008, 09:35:54 AM
Looks promising, I will try this out.

Would this work if my smf is behind a portal?  ???
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 05, 2008, 11:20:06 AM
I don't have a portal to try it on, but I would think so, or can't think of any reason why not. Please let us know how it works out.
Title: Re: Add an Apache Error Handler to SMF
Post by: Bancherd on September 05, 2008, 06:54:10 PM
Installed this with smf2beta4 and PortaMx, looking good!  :D

Thanks for the mod  :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on September 05, 2008, 07:01:37 PM
Ah good, glad you like it!

Each time I see a post to this thread I get nervous. Thinkin', "Oh God! Somebody's .htaccess file mods burned down their site..." :)

There's really no worry of that because the mod saves your old .htaccess file if you had one. You can fix it all by FTP if anything untowards happens, and without the .htaccess file the mod is dormant.

Hey, I forgot to tell you, there's an Easter egg in this mod. Try ?action=error with no error code. ;)
Title: Re: Add an Apache Error Handler to SMF
Post by: Bancherd on September 05, 2008, 07:07:18 PM


Found it.....Hahaha
Title: Re: Add an Apache Error Handler to SMF
Post by: edi67 on September 14, 2008, 10:07:41 AM
excellent work ;)
Title: Re: Add an Apache Error Handler to SMF
Post by: bluegray on September 15, 2008, 07:18:07 AM
Quote from: Charles Hill on September 02, 2008, 03:52:00 PM
I have weighed the usefulness of Pretty URLs mod vs this mod.  I have chosen this mod.  I had to add a little code to auto-redirect users from old "pretty" URLs to their un-pretty counterparts, but I like this mod :)
Could you please share how you did this? Is it just a few .htaccess RewriteRules? Would like to try it out, but I currently have PrettyUrls installed.
Title: Re: Add an Apache Error Handler to SMF
Post by: edi67 on September 15, 2008, 05:16:43 PM
work perfectly some example

http://ediboard.altervista.org/cache

http://ediboard.altervista.org/nosome_nonexistent_page.html
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on October 07, 2008, 09:50:51 AM
Quote from: bluegray on September 15, 2008, 07:18:07 AM
Quote from: Charles Hill on September 02, 2008, 03:52:00 PM
I have weighed the usefulness of Pretty URLs mod vs this mod.  I have chosen this mod.  I had to add a little code to auto-redirect users from old "pretty" URLs to their un-pretty counterparts, but I like this mod :)
Could you please share how you did this? Is it just a few .htaccess RewriteRules? Would like to try it out, but I currently have PrettyUrls installed.

I'm sorry that I missed your question before. Yes, the modification is a combination of two things: It adds a series of Apache directives in the form "ErrorDocument 404 /index.php?action=error;code=404" to your .htaccess file or creates the .htaccess file if none exists. And it adds an error handler to respond to the "?action=error" requests which logs the error event and then displays an error page to the user.

I have no idea if it works with the PrettyURLs mod but it would be interesting to find out.
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on October 07, 2008, 09:51:26 AM
This modification has been verified to work properly with both SMF 1.1.6 and SMF 2.0 Beta 4.
Title: Re: Add an Apache Error Handler to SMF
Post by: Bancherd on October 07, 2008, 06:34:42 PM
This is a very good mod(along with The Rules :D )....it helped me find  errors while using my test site; which would be difficult to find otherwise.

There is a warning though.....it does not like my local test box(xampp+windows)....always bombed on mod's installation.  Is there a simple work around?
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on October 07, 2008, 06:41:59 PM
All my mod packages are very good. ;) ;) ;)

I can't think of why it wouldn't work on Xampp (which does have Apache) but I have no experience with Xampp and no test setup for that. All my testing is done on shared hosting test sites using Apache/PHP/Unix etc. provided by the hosting service, a pretty standard setup. But it isn't Xampp.

I have no way of testing it so there is no way that I can find out why it doesn't work on Xampp.


Yes, it is a good package for spotting errors. That's the main advantage of installing this mod package, although the error pages the user sees is also a benefit.

Have fun! :)
Title: Re: Add an Apache Error Handler to SMF
Post by: shadow82x on October 09, 2008, 06:09:17 PM
Very interesting mod. :D Thanks for sharing.
Title: Re: Add an Apache Error Handler to SMF
Post by: blondeamon on October 14, 2008, 01:24:33 PM
It would be super great if you could make it work for lightptd servers as well.

Is it possible mate?
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on October 14, 2008, 03:46:35 PM
Well it might be possible for you to just configure your LightTpd options to partially use the mod even now. I was surfing their site and noted an option "server.error-handler-404" which can be set to point to an error document. If you point that to "/index.php?action=error;code=404" I expect that SMF would log the error and send the error page.

If there is a corresponding setting for 403 Forbidden then you would already have probably 98% of likely errors already covered because most errors result from file not found or access forbidden.

You should seek advice from some LightTpd experts and see if these two and possibly any other errors could be covered. It would be a manual configuration but you only need to set it up once.

Plesase let me know if you find anything. :)
Title: Re: Add an Apache Error Handler to SMF
Post by: bjraines on October 21, 2008, 05:35:29 PM
I am very curious about this mod

my problem is that if I have links that no longer exists, the forum defualts to the index page and show NO 404 page
Title: Re: Add an Apache Error Handler to SMF
Post by: bjraines on October 22, 2008, 08:33:01 AM
I tried using this mod yesterday, and foolishly on my part i didn't realize it might not work with pretty urls mod

is there a way to get this to work as I could really use the 404 pages
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on October 22, 2008, 08:44:27 AM
The Apache Error Handler and Pretty URLs mods are mutually incompatible. Sorry.
Title: Re: Add an Apache Error Handler to SMF
Post by: bjraines on October 22, 2008, 09:50:35 AM
I see,

Although I have long left it, I used to be big into Joomla

most of the SEF (pretty) URL extensiosn and 404 are tied together in some way.

thanks for replying!
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on October 22, 2008, 10:51:33 AM
I'm sorry that my reply couldn't be more useful.
Title: Re: Add an Apache Error Handler to SMF
Post by: bjraines on October 22, 2008, 03:22:50 PM
hey no problem...i just wish it could work for me

maybe i can find a fix somehow because I really need a good 404 page
Title: Re: Add an Apache Error Handler to SMF
Post by: L'AltroWeb on November 24, 2008, 09:51:56 AM
Quote from: Deprecated on October 22, 2008, 08:44:27 AM
The Apache Error Handler and Pretty URLs mods are mutually incompatible. Sorry.
I've installed with pretty urls and after some little edit on .htaccess now all seems to works fine :)
http://darkwolf.altervista.org/smf2/index.php
Simply put this code # beginning of directives for Apache Error Handling modification
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)  /smf2/index.php?action=error;code=404
ErrorDocument 400 /smf2/index.php?action=error;code=400
ErrorDocument 401 /smf2/index.php?action=error;code=401
ErrorDocument 402 /smf2/index.php?action=error;code=402
ErrorDocument 403 /smf2/index.php?action=error;code=403
ErrorDocument 404 /smf2/index.php?action=error;code=404
ErrorDocument 405 /smf2/index.php?action=error;code=405
ErrorDocument 406 /smf2/index.php?action=error;code=406
ErrorDocument 407 /smf2/index.php?action=error;code=407
ErrorDocument 408 /smf2/index.php?action=error;code=408
ErrorDocument 409 /smf2/index.php?action=error;code=409
ErrorDocument 410 /smf2/index.php?action=error;code=410
ErrorDocument 411 /smf2/index.php?action=error;code=411
ErrorDocument 412 /smf2/index.php?action=error;code=412
ErrorDocument 413 /smf2/index.php?action=error;code=413
ErrorDocument 414 /smf2/index.php?action=error;code=414
ErrorDocument 415 /smf2/index.php?action=error;code=415
ErrorDocument 416 /smf2/index.php?action=error;code=416
ErrorDocument 417 /smf2/index.php?action=error;code=417
ErrorDocument 500 /smf2/index.php?action=error;code=500
ErrorDocument 501 /smf2/index.php?action=error;code=501
ErrorDocument 502 /smf2/index.php?action=error;code=502
ErrorDocument 503 /smf2/index.php?action=error;code=503
ErrorDocument 504 /smf2/index.php?action=error;code=504
ErrorDocument 505 /smf2/index.php?action=error;code=505
# end of directives for Apache Error Handling modification
at the end of htaccess generated by pretty url.
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on November 24, 2008, 11:04:57 AM
I will appreciate more reports on whether Dark Wolf's suggestion works, i.e. to make Pretty URLs and my mod play together by putting my .htaccess data at the end of the file. I was worried that unknown .htaccess commands could prevent my mod from working unless I put my codes at the top. If the suggested fix works then we can add an application note to help Pretty URLs users integrate the Apache Error Handler.
Title: Re: Add an Apache Error Handler to SMF
Post by: L'AltroWeb on November 24, 2008, 11:12:04 AM
:)
If is util, this is my entire htaccess
# Pretty URLs mod
# http://code.google.com/p/prettyurls/
# .htaccess file generated automatically on: November 22, 2008, 18:21

RewriteEngine on
#change /smf2 with your forum directory eg: /forum
RewriteBase /smf2

# Rules for: profiles
RewriteRule ^profile/([^/]+)/?$ ./index.php?pretty;action=profile;user=$1 [L,QSA]

# Rules for: actions
RewriteRule ^(activate|admin|announce|attachapprove|buddy|calendar|clock|collapse)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(contact|coppa|credits|deletemsg|display|dlattach|editpoll|editpoll2|emailuser)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(findmember|forum|groups|guestbook|help|downloads|helpadmin|im|jseditor)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(jsmodify|jsoption|lock|lockvoting|login|login2|logout|markasread)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(mascot|mergetopics|mgallery|mlist|moderate|modifycat|modifykarma|movetopic|movetopic2)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(notify|notifyboard|openidreturn|pm|post|post2|printpage|profile)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(quotefast|quickmod|quickmod2|recent|register|register2|reminder|removepoll)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(removetopic2|reporttm|requestmembers|restoretopic|search|search2|sendtopic|smstats)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(suggest|spellcheck|splittopics|stats|sticky|theme|trackip|about:mozilla)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(about:unknown|unread|unreadreplies|verificationcode|viewprofile|vote|viewquery|viewsmfile)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(who|\.xml|xmlhttp)/?$ ./index.php?pretty;action=$1 [L,QSA]

# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

# beginning of directives for Apache Error Handling modification
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)  /smf2/index.php?action=error;code=404
ErrorDocument 400 /smf2/index.php?action=error;code=400
ErrorDocument 401 /smf2/index.php?action=error;code=401
ErrorDocument 402 /smf2/index.php?action=error;code=402
ErrorDocument 403 /smf2/index.php?action=error;code=403
ErrorDocument 404 /smf2/index.php?action=error;code=404
ErrorDocument 405 /smf2/index.php?action=error;code=405
ErrorDocument 406 /smf2/index.php?action=error;code=406
ErrorDocument 407 /smf2/index.php?action=error;code=407
ErrorDocument 408 /smf2/index.php?action=error;code=408
ErrorDocument 409 /smf2/index.php?action=error;code=409
ErrorDocument 410 /smf2/index.php?action=error;code=410
ErrorDocument 411 /smf2/index.php?action=error;code=411
ErrorDocument 412 /smf2/index.php?action=error;code=412
ErrorDocument 413 /smf2/index.php?action=error;code=413
ErrorDocument 414 /smf2/index.php?action=error;code=414
ErrorDocument 415 /smf2/index.php?action=error;code=415
ErrorDocument 416 /smf2/index.php?action=error;code=416
ErrorDocument 417 /smf2/index.php?action=error;code=417
ErrorDocument 500 /smf2/index.php?action=error;code=500
ErrorDocument 501 /smf2/index.php?action=error;code=501
ErrorDocument 502 /smf2/index.php?action=error;code=502
ErrorDocument 503 /smf2/index.php?action=error;code=503
ErrorDocument 504 /smf2/index.php?action=error;code=504
ErrorDocument 505 /smf2/index.php?action=error;code=505
# end of directives for Apache Error Handling modification

Some little difference from original prettyurls htaccess (guestbook, contact and mgalley)  ;)
Title: Re: Add an Apache Error Handler to SMF
Post by: bjraines on November 24, 2008, 04:19:48 PM
i am about to try it (if my gf doesn't come over and make me get off the comp)

Is there two .htaccess one from pretty url and one for this mod?
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on November 24, 2008, 04:58:58 PM
Nope, that's the problem, you can't have two files with the same name. Obviously.

Probably the easiest thing you can do is to go ahead with installing the mod, then before you even try to access your forum you should download the .htaccess file and put my stuff at the end.

Everybody should understand that if I reprogram this mod to put my stuff at the end, it could just as easily break other .htaccess configurations. We could be just trading one set of problems for a different set of problems. However, I'm giving this matter a great deal of thought, and if there's a better way of doing it I'm certainly going to look into doing it that way.

You should understand that my modification makes a backup copy of your .htaccess and calls it .htaccess~ so it's not going to leave you up the creek without a paddle. However it wouldn't hurt to back up your file manually. If you have any problems you can always copy over.

I'm also thinking of supplying a version of this mod that leaves the .htaccess alone. It would then require manual .htaccess edits to put it into operation, but it would avoid colliding with Pretty URLs. I'm going to do something about this, but not until the best solution is evident, and I'm not going to do two contradictory things either.

Really, this is a good mod. I think everybody should run it, and I'm trying to work out exactly what the best solution is.
Title: Re: Add an Apache Error Handler to SMF
Post by: Reverend Jeremiah on November 25, 2008, 08:30:19 AM
Add an Apache Error Handler to SMF review

by Reverend Jeremiah

Rated: ***** (5 stars)

Do you have a massive forum? Did you just upgrade from making your own html web pages to using Simple Machines Forum as your Content Management System? Have you gone from pretty URL's to something that looks like a comic book character cussing you out? Do you think that an "Apache error handler" is an American Native with a tomahawk and a bad attitude? Then this Mods for you!

"Add an Appache error handler to SMF" will fix ALL of your dead links to at least open up a proffessional looking template page as opposed to that white page that says "404 error, page not found" that makes your visitors think your website is no longer up and running. Words cannot express how important having a custom error handler on your site in conjunction with a favicon.ico file on your site is. Do you want your hard earned google and yahoo page caches to pull up a screen that looks like your site is shut down permanent to people who dont know the difference? I suggest that this mod be the VERY FIRST mod you install on your SMF along with somekind of favicon mod (or you can just hard code the favicon into the meta like I did.). This Mod deserves 5 stars because it is quick and effective, and the support forum is wonderfully detailed.

So, do you want that Appache error handler frightening your potential visitors away or do you want to grab him by the balls and turn him into a tour guide? If you have the guts, then go over to this URL (http://custom.simplemachines.org/mods/index.php?mod=1363) and take back control of your site RIGHT NOW!
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on November 25, 2008, 08:42:40 AM
Please be advised that I have updated this modification for the following:

Version 1.1 (Nov. 25, 2008) Added British and British UTF-8 language strings.

Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=1363)

Existing installations do not need to be upgraded unless they are using British or British UTF-8 language settings and are having language problems.
Title: Re: Add an Apache Error Handler to SMF
Post by: Melfina on January 22, 2009, 10:08:11 AM
Quote from: Deprecated on November 24, 2008, 11:04:57 AM
I will appreciate more reports on whether Dark Wolf's suggestion works, i.e. to make Pretty URLs and my mod play together by putting my .htaccess data at the end of the file. I was worried that unknown .htaccess commands could prevent my mod from working unless I put my codes at the top. If the suggested fix works then we can add an application note to help Pretty URLs users integrate the Apache Error Handler.

Works for me, just installed it with pretty urls already installed, added the .htaccess rules at the bottom and re-uploaded the .htacess file.
Title: Re: Add an Apache Error Handler to SMF
Post by: L'AltroWeb on January 25, 2009, 10:46:08 PM
I have a small problem with google: http://www.google.it/search?hl=it&q=darkwolf+404&meta=  :-\
Now i've put this in robots.txt:
QuoteDisallow: /forum/index.php?action=error
;)
Title: Re: Add an Apache Error Handler to SMF
Post by: L'AltroWeb on January 30, 2009, 10:32:07 PM
Hi!
Now thanks to Dannii we (pretty urls users) can run "maintenance" without any problem for apache error handler :)
http://www.simplemachines.org/community/index.php?topic=146969.msg1904481#msg1904481
Title: Re: Add an Apache Error Handler to SMF
Post by: .HuNTeR. on February 09, 2009, 09:28:58 AM
hi Deprecated
i tried to disable this mod in one of my forum sub folders with a .htaccess file in that folder with this codes:
<Directory />
AllowOverride None
</Directory>
but I'm just getting 500 internal server error
whats the problem?
Title: Re: Add an Apache Error Handler to SMF
Post by: speedyuk7 on May 29, 2009, 08:49:35 AM
Most usefull mod i ever seen
Title: Re: Add an Apache Error Handler to SMF
Post by: shaitanfr on June 07, 2009, 06:48:47 AM
Working solution with pretty urls.

Always update .htaccess with the script after doing maintenance task in pretty url.

In UpdateHtaccess.php

Find
$contents .= file_get_contents($htaccess_file_name);

Just after add:

$contents .= $contents2;


Apache Error wil be automatically placed after Url rewriting lines:


RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

# beginning of directives for Apache Error Handling modification

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule (.*)  /index.php?action=error;code=404

ErrorDocument 400 /index.php?action=error;code=400

ErrorDocument 401 /index.php?action=error;code=401

ErrorDocument 402 /index.php?action=error;code=402



Quote from: Dark-Wolf on January 30, 2009, 10:32:07 PM
Hi!
Now thanks to Dannii we (pretty urls users) can run "maintenance" without any problem for apache error handler :)
http://www.simplemachines.org/community/index.php?topic=146969.msg1904481#msg1904481

I have discover your solution only now. Good too.  :)
Title: Re: Add an Apache Error Handler to SMF
Post by: speedyuk7 on June 07, 2009, 06:58:55 AM
I did it differently to work with pretty urls. First part of htaccess was the apache stuff, and 2nd part the prettyurls. What i did is i switched places, pretty urls first, apache second. and works
Title: Re: Add an Apache Error Handler to SMF
Post by: shaitanfr on June 07, 2009, 07:28:40 AM
Quote from: speedyuk7 on June 07, 2009, 06:58:55 AM
I did it differently to work with pretty urls. First part of htaccess was the apache stuff, and 2nd part the prettyurls. What i did is i switched places, pretty urls first, apache second. and works

Yes, but what append when you do maintenance task in pretty url ?
Title: Re: Add an Apache Error Handler to SMF
Post by: speedyuk7 on June 10, 2009, 06:00:47 AM
Never did the maintenance , what does that do anyways?
Anyway wheres this file UpdateHtaccess.php cant find it
Title: Re: Add an Apache Error Handler to SMF
Post by: shaitanfr on June 10, 2009, 06:05:55 AM
Quote from: speedyuk7 on June 10, 2009, 05:56:52 AM
"maintenance task in pretty url"
Didn't understand that sorry :X Could you explain what you mean

(http://passion-xbmc.org/fichiers_multimedia/upploadimages/miniatures/1244628185-maintenance-de-pretty-urls---opera.jpg) (http://passion-xbmc.org/fichiers_multimedia/upploadimages/images/1244628185-maintenance-de-pretty-urls---opera.jpg)

Maintenance Tools in pretty url rewrite the .htaccess.

Maintenance tools is usefull for adding new actions when you add a mod and for other reason I can't explain in english, sorry.
Title: Re: Add an Apache Error Handler to SMF
Post by: speedyuk7 on June 10, 2009, 06:12:09 AM
And where is this file UpdateHtaccess.php ? I cant find it anywhere on ftp
Title: Re: Add an Apache Error Handler to SMF
Post by: shaitanfr on June 10, 2009, 06:31:22 AM
Quote from: speedyuk7 on June 10, 2009, 06:12:09 AM
And where is this file UpdateHtaccess.php ? I cant find it anywhere on ftp

From the Author:

QuoteNote: If desired, the included UpdateHtaccess.php file can be run stand-alone in your board directory to modify or demodify your .htaccess file. Use 'UpdateHtaccess.php' to install the .htaccess file changes. Use 'UpdateHtaccess.php?uninstall' to remove the .htaccess file changes. Or alternately, you can just manually edit or delete your .htaccess fie.
Title: Re: Add an Apache Error Handler to SMF
Post by: speedyuk7 on June 10, 2009, 07:17:31 AM
But I dont have this file on my ftp,
Title: Re: Add an Apache Error Handler to SMF
Post by: shaitanfr on June 10, 2009, 07:29:48 AM
The file is in the package but not installed. Optionnal for manually update.
Title: Re: Add an Apache Error Handler to SMF
Post by: ElectricSquid on July 07, 2009, 09:13:25 PM
Quote from: DeprecatedEach time I see a post to this thread I get nervous. Thinkin', "Oh God! Somebody's .htaccess file mods burned down their site..."

Maybe so, but think of how many of us have heathy forums because of your mod.
In my opinion, this is the most useful admin mod ever written. It shows all the dirty little errors that are hiding from the admins view.

...BUT :P

I would like to suggest placing a [BACK] button on each error page, so the user can go back to the last working page they were on and try to create some other errors.

Anyone have any generic code they could share that would send the user back?
That's not a function I'm familiar with yet.
Title: Re: Add an Apache Error Handler to SMF
Post by: Juo on July 22, 2009, 02:34:41 PM
Just installed on SMF 2.0 RC1.2, works a treat. Thanks :)
Title: Re: Add an Apache Error Handler to SMF
Post by: ElectricSquid on July 22, 2009, 10:22:57 PM
How do I add support for showing 301 redirects.
I'd like to track these to make sure they're working properly. Also to track users trying to reach certain moved pages that throw a [301].



Thanks a million for this mod.
There were a few file not found errors coming from my excessive custom coding. I wouldn't have been able to track them down so easily without this mod.
Title: Re: Add an Apache Error Handler to SMF
Post by: kai920 on August 05, 2009, 06:14:22 PM
Quote from: Deprecated on September 02, 2008, 06:33:39 PM
This modification installs or alters an .htaccess in the same directory as your forum's index.php, e.g. /forum. Apache will use that .htaccess file only for the /forum directory and subdirectories underneath it. Errors from above your /forum directory will be handled by whatever rules exist in higher level .htaccess files or by your hosting service's default error handlers.

Thanks for this awesome mod. I just converted to a SMF-only site so this has been great in catching the 404s.

However, my forum is in a subdirectory /forums - is there a quick way to get your mod to also catch errors at the / (root) level? Perhaps by altering the main directory's .htaccess?

Thanks again!
Title: Re: Add an Apache Error Handler to SMF
Post by: LHW on August 06, 2009, 08:06:43 AM
Nice Mod, Deprecated!  Thank you!
Title: Re: Add an Apache Error Handler to SMF
Post by: kai920 on August 10, 2009, 06:15:14 PM
Any one have any ideas about my issue? (2 posts up)
Title: Re: Add an Apache Error Handler to SMF
Post by: HR on September 18, 2009, 06:02:38 AM
I just want a switch to turn off the error reporting for this mod.. my logs are frightening!

I did however come up with this..
**Im using 2.0rc something..

Sources/Errors.php

// What types of categories do we have?
$known_error_types = array(
'general',
'critical',
'database',
'undefined_vars',
'user',
'template',
'debug',

Add
'Apache',


And your Sources/ApacheErrors.php

log_error($context['apache_err_msg'] . ' (' . $context['request_url'] . ')', 'user');


Change it to read:
log_error($context['apache_err_msg'] . ' (' . $context['request_url'] . ')', 'Apache');



Now when I do the error logs Apache errors have their own sorting option so they can be viewed separately and also mass removed. IF you comment out the log error line then errors are no longer reported to the error log ;)
Title: Re: Add an Apache Error Handler to SMF
Post by: HR on September 18, 2009, 06:33:23 AM
Quote from: kai920 on August 10, 2009, 06:15:14 PM
Any one have any ideas about my issue? (2 posts up)

I would think copying the htaccess file over but edit it to reflect your relative forum path would resolve the issue and make it function the way your after.
Title: Re: Add an Apache Error Handler to SMF
Post by: sshahnawaz on October 08, 2009, 08:15:48 AM
Thanks very much for such a nice modification to SMF. I have a small problem, I want to add a few lines more to the default error message which this mod provides. Is there any way to do it? Thanks in advance...  :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on October 08, 2009, 08:28:41 AM
Edit the ApacheError.template.php and add your text to your Modifications.english.php
Title: Re: Add an Apache Error Handler to SMF
Post by: sshahnawaz on October 08, 2009, 09:07:04 AM
Thanks for a quick response.  :D
Where do these exist, i.e. ApacheError.template.php and Modifications.english.php... I just want to add one line or two in the error display message. Is it necessary to change ApacheErro.template for that or it is enough to just add those lines in Modifications.english.php?
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on October 08, 2009, 09:16:50 AM
Yes you could add those lines to an existing string in  Themes/default/languages/Modifications.english.php, or rewrite the string,
or add your own into the template  Themes/default/ApacheError.template.php, and add the text to your  Modifications.english.php
eg. add $txt['your_message'] = 'insert text here'; to your Modifications.english.php
then add ', $txt['your_message'] ,' where you would like the text to display in the ApacheError.template.php

Editing an existing string in your Modifications.english.php would be easier for some.

Good luck :)
Title: Re: Add an Apache Error Handler to SMF
Post by: sshahnawaz on October 08, 2009, 12:56:37 PM
Thank you very much for your good answer. I have solved this issue. Glad to know how to make this change and others if necessary.   :)
Title: Re: Add an Apache Error Handler to SMF
Post by: Afro on December 28, 2009, 06:30:03 AM
Quote from: Charles Hill on September 02, 2008, 03:52:00 PM
I have weighed the usefulness of Pretty URLs mod vs this mod.  I have chosen this mod.  I had to add a little code to auto-redirect users from old "pretty" URLs to their un-pretty counterparts, but I like this mod :)

This is interesting because i removed my pretty url mod for this too but i cant do the code to redirect to pretty urls already indexed by google.
Its generating hundreds of errors an hour .

Please can someone help me here ?
Title: Re: Add an Apache Error Handler to SMF
Post by: carderne on January 07, 2010, 05:15:35 PM
I have this mod installed together with Pretty URLs and I moved the code for this mod to the bottom of .htaccess. The problem now is that any address just redirects to the home page, instead of displaying the proper error message.

Here are the contents of my .htaccess file:

# PRETTYURLS MOD BEGINS
# Pretty URLs mod
# http://code.google.com/p/prettyurls/
# .htaccess file generated automatically on: January 7, 2010, 23:32

RewriteEngine on
RewriteBase /

# Rules for: actions
RewriteRule ^(activate|admin|announce|ban|boardrecount|buddy|calendar|cleanperms)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(collapse|convertentities|convertutf8|coppa|deletemsg|detailedversion|display|dlattach)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(dumpdb|editpoll|editpoll2|featuresettings|featuresettings2|findmember|help|helpadmin)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(im|jsoption|jsmodify|lock|lockVoting|login|login2|logout)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(maintain|manageattachments|manageboards|managecalendar|managesearch|markasread|membergroups|mergetopics)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(mlist|modifycat|modifykarma|modlog|movetopic|movetopic2|news|notify)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(notifyboard|optimizetables|packageget|packages|permissions|pgdownload|pm|post)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(post2|postsettings|printpage|profile|profile2|quotefast|quickmod|quickmod2)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(recent|regcenter|register|register2|reminder|removetopic2|removeoldtopics2|removepoll)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(repairboards|reporttm|reports|requestmembers|search|search2|sendtopic|serversettings)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(serversettings2|smileys|smstats|spellcheck|splittopics|stats|sticky|theme)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(trackip|about:mozilla|about:unknown|unread|unreadreplies|viewErrorLog|viewmembers|viewprofile)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(verificationcode|vote|viewquery|who|\.xml)/?$ ./index.php?pretty;action=$1 [L,QSA]

# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

# PRETTYURLS MOD ENDS

# beginning of directives for Apache Error Handling modification
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)  /index.php?action=error;code=404
ErrorDocument 400 /index.php?action=error;code=400
ErrorDocument 401 /index.php?action=error;code=401
ErrorDocument 402 /index.php?action=error;code=402
ErrorDocument 403 /index.php?action=error;code=403
ErrorDocument 404 /index.php?action=error;code=404
ErrorDocument 405 /index.php?action=error;code=405
ErrorDocument 406 /index.php?action=error;code=406
ErrorDocument 407 /index.php?action=error;code=407
ErrorDocument 408 /index.php?action=error;code=408
ErrorDocument 409 /index.php?action=error;code=409
ErrorDocument 410 /index.php?action=error;code=410
ErrorDocument 411 /index.php?action=error;code=411
ErrorDocument 412 /index.php?action=error;code=412
ErrorDocument 413 /index.php?action=error;code=413
ErrorDocument 414 /index.php?action=error;code=414
ErrorDocument 415 /index.php?action=error;code=415
ErrorDocument 416 /index.php?action=error;code=416
ErrorDocument 417 /index.php?action=error;code=417
ErrorDocument 500 /index.php?action=error;code=500
ErrorDocument 501 /index.php?action=error;code=501
ErrorDocument 502 /index.php?action=error;code=502
ErrorDocument 503 /index.php?action=error;code=503
ErrorDocument 504 /index.php?action=error;code=504
ErrorDocument 505 /index.php?action=error;code=505
# end of directives for Apache Error Handling modification


Thanks for your help.
Title: Re: Add an Apache Error Handler to SMF
Post by: Cap. Price on January 07, 2010, 07:37:53 PM
I love it :) , thank U very much.

Spanish Translation:

$txt['apache_err'] = 'Error';
$txt['apache_err_rqst_url'] = 'URL solicitada:';
$txt['apache_err_400_msg'] = 'Error 400 - Petici&oacute;n Err&oacute;nea';
$txt['apache_err_400_dsc'] = 'La solicitud contiene sintaxis err&oacute;nea y no deber&iacute;a repetirse.';
$txt['apache_err_401_msg'] = 'Error 401 - No Autorizado';
$txt['apache_err_401_dsc'] = 'No tiene autorizaci&oacute;n para acceder a esta p&aacute;gina.';
$txt['apache_err_402_msg'] = 'Error 402 - Pago Requerido';
$txt['apache_err_402_dsc'] = 'Codigo de error n&uacute;nca implementado. Reservado para uso futuro.';
$txt['apache_err_403_msg'] = 'Error 403 - Prohibido';
$txt['apache_err_403_dsc'] = 'Permisos insuficientes para leer esta p&aacute;gina o directorio.';
$txt['apache_err_404_msg'] = 'Error 404 - No Encontrado';
$txt['apache_err_404_dsc'] = 'No se encontr&oacute; la p&aacute;gina. Puede que la p&aacute;gina solicitada ya no exista, haya cambiado de nombre o no est&eacute; disponible temporalmente.';
$txt['apache_err_405_msg'] = 'Error 405 - M&eacute;todo no Permitido';
$txt['apache_err_405_dsc'] = 'Una petici&oacute;n fue hecha a una URI utilizando un m&eacute;todo de solicitud no soportado por dicha URI.';
$txt['apache_err_406_msg'] = 'Error 406 - No Aceptable';
$txt['apache_err_406_dsc'] = 'No se puede abrir el recurso.';
$txt['apache_err_407_msg'] = 'Error 407 - Autenticaci&oacute;n Proxy Requerida';
$txt['apache_err_407_dsc'] = 'Debe autenticar con un servidor proxy antes de atender esta solicitud. Inicie sesi&oacute;n en el servidor proxy e int&eacute;ntelo de nuevo.';
$txt['apache_err_408_msg'] = 'Error 408 - Tiempo de Espera Agotado';
$txt['apache_err_408_dsc'] = 'Su navegador o su conexi&oacute;n a fallado al intentar abrir la p&aacute;gina solicitada. Int&eacute;ntelo de nuevo en unos minutos.';
$txt['apache_err_409_msg'] = 'Error 409 - Conflicto';
$txt['apache_err_409_dsc'] = 'La llamada no se ha podido completar debido a un conflicto por el estado actual del recurso.';
$txt['apache_err_410_msg'] = 'Error 410 - Movido';
$txt['apache_err_410_dsc'] = 'El recurso pedido ya no est&aacute; disponible en el servidor y ninguna direcci&oacute;n que se remite es conocida. Esta condici&oacute;n debe ser considerada permanente.';
$txt['apache_err_411_msg'] = 'Error 411 - Longitud Requerida';
$txt['apache_err_411_dsc'] = 'El servidor se niega a aceptar la demanda sin una longitud de volumen definida.';
$txt['apache_err_412_msg'] = 'Error 412 - Condici&oacute;n Previa Fallida';
$txt['apache_err_412_dsc'] = 'La condici&oacute;n previa cedida en uno o m&aacute;s de los campos del t&iacute;tulo de petici&oacute;n evalu&oacute; a falso cuando se prob&oacute; en el servidor.';
$txt['apache_err_413_msg'] = 'Error 413 - Entidad de la Demanda Demasiado Grande';
$txt['apache_err_413_dsc'] = 'El servidor est&aacute; neg&aacute;ndose a procesar una demanda porque la entidad de la demanda es m&aacute;s grande de lo que el servidor desea o es capaz de procesar.';
$txt['apache_err_414_msg'] = 'Error 414 - URI Demasiado Larga';
$txt['apache_err_414_dsc'] = 'El servidor est&aacute; neg&aacute;ndose a procesar una demanda porque la URI especificada es m&aacute;s grande de lo que el servidor desea o es capaz de procesar.';
$txt['apache_err_415_msg'] = 'Error 415 - Tipo de Medio no Soportado';
$txt['apache_err_415_dsc'] = 'El servidor est&aacute; rechazando la demanda porque la entidad de la demanda est&aacute; en un formato no apoyado por el recurso pedido para el m&eacute;todo solicitado.';
$txt['apache_err_416_msg'] = 'Error 416 - Rango Solicitado no Disponible';
$txt['apache_err_416_dsc'] = 'El cliente ha preguntado por una parte de un archivo, pero el servidor no puede proporcionar esa parte.';
$txt['apache_err_417_msg'] = 'Error 417 - Fall&oacute; expectativa';
$txt['apache_err_417_dsc'] = 'Las expectativas que se dan en una expectativa de solicitud en el campo de cabecera no puede ser alcanzado por este servidor.';
$txt['apache_err_500_msg'] = 'Error 500 - Error Interno del Servidor';
$txt['apache_err_500_dsc'] = 'El servidor encontr&oacute; una condici&oacute;n inesperada que le impidi&oacute; cumplir la demanda.';
$txt['apache_err_501_msg'] = 'Error 501 - No Implementado';
$txt['apache_err_501_dsc'] = 'El servidor no soporta la funcionalidad que se exigi&oacute; para cumplir la demanda.';
$txt['apache_err_502_msg'] = 'Error 502 - Entrada Err&oacute;nea';
$txt['apache_err_502_dsc'] = 'El servidor, mientras actuaba como una gateway o proxy, recibi&oacute; una contestaci&oacute;n inv&aacute;lida desde el servidor del upstream y accedi&oacute; intentando cumplir la demanda.';
$txt['apache_err_503_msg'] = 'Error 503 - Servicio no Disponible';
$txt['apache_err_503_dsc'] = 'El servidor es actualmente incapaz de ocuparse de la demanda debido a una sobrecarga o mantenimiento temporal del servidor.';
$txt['apache_err_504_msg'] = 'Error 504 - Tiempo de Espera Agotado';
$txt['apache_err_504_dsc'] = 'El servidor, mientras actuaba como un gateway o proxy, no recibi&oacute; una contestaci&oacute;n oportuna del servidor upstream que accedi&oacute; intentando completar la demanda.';
$txt['apache_err_505_msg'] = 'Error 505 - Versi&oacute;n de HTTP no Soportada';
$txt['apache_err_505_dsc'] = 'El servidor no soporta, o se niega a soportar, el protocolo de versi&oacute;n HTTP que se us&oacute; en el mensaje de la demanda.';
$txt['apache_err_999_msg'] = 'Error Desconocido';
$txt['apache_err_999_dsc'] = 'El servidor no puede determinar el tipo de error ocurrido.';
Title: Re: Add an Apache Error Handler to SMF
Post by: KensonPlays on January 19, 2010, 08:07:10 PM
Thanks! Helps with GoDaddy linux apache stuff!
Title: Re: Add an Apache Error Handler to SMF
Post by: luismanson on January 21, 2010, 07:04:52 PM
is anyone using this great mod with pretty urls? i see some people with problems and i dont wana risk my live forum :(
Title: Re: Add an Apache Error Handler to SMF
Post by: luismanson on January 21, 2010, 07:34:31 PM
ok, i tested anyways... if i go to a non existen page it goes directly to the main index without notice :(

my htaccess

# beginning of directives for Apache Error Handling modification
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)  /index.php?action=error;code=404
ErrorDocument 400 /index.php?action=error;code=400
ErrorDocument 401 /index.php?action=error;code=401
ErrorDocument 402 /index.php?action=error;code=402
ErrorDocument 403 /index.php?action=error;code=403
ErrorDocument 404 /index.php?action=error;code=404
ErrorDocument 405 /index.php?action=error;code=405
ErrorDocument 406 /index.php?action=error;code=406
ErrorDocument 407 /index.php?action=error;code=407
ErrorDocument 408 /index.php?action=error;code=408
ErrorDocument 409 /index.php?action=error;code=409
ErrorDocument 410 /index.php?action=error;code=410
ErrorDocument 411 /index.php?action=error;code=411
ErrorDocument 412 /index.php?action=error;code=412
ErrorDocument 413 /index.php?action=error;code=413
ErrorDocument 414 /index.php?action=error;code=414
ErrorDocument 415 /index.php?action=error;code=415
ErrorDocument 416 /index.php?action=error;code=416
ErrorDocument 417 /index.php?action=error;code=417
ErrorDocument 500 /index.php?action=error;code=500
ErrorDocument 501 /index.php?action=error;code=501
ErrorDocument 502 /index.php?action=error;code=502
ErrorDocument 503 /index.php?action=error;code=503
ErrorDocument 504 /index.php?action=error;code=504
ErrorDocument 505 /index.php?action=error;code=505
# end of directives for Apache Error Handling modification

# PRETTYURLS MOD BEGINS
# Pretty URLs mod
# http://code.google.com/p/prettyurls/
# .htaccess file generated automatically on: December 31, 2009, 4:06

RewriteEngine on
RewriteBase /

# Rules for: profiles
RewriteRule ^profile/([^/]+)/?$ ./index.php?pretty;action=profile;user=$1 [L,QSA]

# Rules for: actions
RewriteRule ^(activate|admin|announce|attachapprove|buddy|calendar|clock|collapse)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(coppa|credits|deletemsg|display|dlattach|editpoll|editpoll2|emailuser)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(findmember|groups|help|helpadmin|im|jseditor|jsmodify|jsoption)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(lock|lockvoting|login|login2|logout|markasread|mergetopics|mlist)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(moderate|modifycat|modifykarma|movetopic|movetopic2|notify|notifyboard|openidreturn)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(pm|post|post2|printpage|profile|quotefast|quickmod|quickmod2)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(recent|register|register2|reminder|removepoll|removetopic2|reporttm|requestmembers)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(restoretopic|search|search2|sendtopic|smstats|suggest|spellcheck|splittopics)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(stats|sticky|theme|trackip|about:mozilla|about:unknown|unread|unreadreplies)/?$ ./index.php?pretty;action=$1 [L,QSA]
RewriteRule ^(verificationcode|viewprofile|vote|viewquery|viewsmfile|who|\.xml|xmlhttp)/?$ ./index.php?pretty;action=$1 [L,QSA]

# Rules for: boards
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([0-9]*)/?$ ./index.php?pretty;board=$1.$2 [L,QSA]

# Rules for: topics
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/?$ ./index.php?pretty;board=$1;topic=$2.0 [L,QSA]
RewriteRule ^([-_!~*'()$a-zA-Z0-9]+)/([-_!~*'()$a-zA-Z0-9]+)/([0-9]*|msg[0-9]*|new)/?$ ./index.php?pretty;board=$1;topic=$2.$3 [L,QSA]

# PRETTYURLS MOD ENDS
Title: Re: Add an Apache Error Handler to SMF
Post by: Sabre™ on February 05, 2010, 07:49:06 AM
Try [THIS] (http://www.simplemachines.org/community/index.php?topic=146969.msg1904481#msg1904481) solution.
I have not tried it, but it seems to have worked for others.
Title: Re: Add an Apache Error Handler to SMF
Post by: coolfx350 on May 16, 2011, 08:17:00 AM
If you think SEO is not important then yes, this mod is awesome, but if you want google traffic, Pretty URL is one of the most important mod out there.

I would give pretty url up.  I wish the author will make this mod compatible with URL.
Title: Re: Add an Apache Error Handler to SMF
Post by: dougiefresh on June 15, 2011, 02:59:30 PM
Thank you for the wonderful mod!  I thought I'd let everybody know that when I updated my forum from 2.0 RC5 to 2.0 Gold, I had to reinstall all my mods.  This mod installed without issues and without emulation.  Hope this info helps someone!
Title: Re: Add an Apache Error Handler to SMF
Post by: Vutrox on September 24, 2011, 10:39:53 AM
I installed this mod before reading this, and I fu**ed up, because I have pretty URLs.. now, can someone tell me what to do, and how can I uninstall this mod (I don't have access to the administrator panel - it shows 404 error) - sry for bad English! xD
Title: Re: Add an Apache Error Handler to SMF
Post by: KensonPlays on October 10, 2011, 11:46:57 AM
Will this work on 2.0.1?
Title: Re: Add an Apache Error Handler to SMF
Post by: HR on January 28, 2012, 01:39:48 PM
Resolved log seperation..

ApacheError.php (in Sources) change 'user' to 'apache'

   log_error($context['apache_err_msg'] . ' (' . $context['request_url'] . ')', 'apache');

in Errors.php (also in Sources) add apache as a category:

   // What types of categories do we have?
   $known_error_types = array(
      'apache',
      'general',
      'critical',
      'database',
      'undefined_vars',
      'user',
      'template',
      'debug',
   );


Now when sorting errors I can determine what is server related and what is a dum dum error (user).
Title: Re: Add an Apache Error Handler to SMF
Post by: Webdzr on April 27, 2012, 10:59:44 AM
I have this mod installed along with pretty urls and everything works great. I just had to put the code below the pretty urls in the .htaccess.

The only problem i have with this mod is that it does show an error message to the user however the header that is sent
always returns 200 ok.

Also the urls like mysite.com/non_exist_page always redirects to the home page its only when the url is like mysite.com/non_exist_page.php does it
go to the error page.

If these two problems were incorperated into this mod it would probably be the most important mod to have.

If anybody knows how to make this mod send out the correct header codes please let me know im having a really hard time with this.

Thank You
Title: Re: Add an Apache Error Handler to SMF
Post by: bearstreet on August 17, 2012, 11:29:34 AM
I included the code for apache handler after pretty urls code in .htaccess ans it seems to be working fine

if anyone is having problems with this mod in union with pretty urls, just include the code for pretty urls before apache handler in your .htaceess and it will work fine
Title: where to put code to use google's 404 error widget
Post by: bearstreet on August 17, 2012, 01:31:38 PM
google webmaster has guidelines to put 404 error widget by placing a code in eror page
http://support.google.com/webmasters/bin/answer.py?hl=en&answer=136085

where should i paste this code?

I pasted this code in
Themes/default/ApacheError.template.php
and this was the result
(see the pic attached)

where should i paste the code so th at the 404 error widget shows up inside the error 404 page and not like what I have in the screenshot
Title: Re: Add an Apache Error Handler to SMF
Post by: Deprecated on January 21, 2014, 10:40:38 AM
This mod is scheduled for update in the near future to 2.0.6 compatibility. I'll have a look at any issues before the release.

And yes, put my code below pretty URLs in your .htaccess. Edit your file if necessary.