News:

Wondering if this will always be free?  See why free is better.

Main Menu

Add an Apache Error Handler to SMF

Started by Deprecated, September 02, 2008, 04:15:47 AM

Previous topic - Next topic

L'AltroWeb

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

.HuNTeR.

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?

speedyuk7


shaitanfr

#63
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.  :)

speedyuk7

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

shaitanfr

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 ?

speedyuk7

#66
Never did the maintenance , what does that do anyways?
Anyway wheres this file UpdateHtaccess.php cant find it

shaitanfr

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



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.

speedyuk7

And where is this file UpdateHtaccess.php ? I cant find it anywhere on ftp

shaitanfr

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.

speedyuk7

But I dont have this file on my ftp,

shaitanfr

The file is in the package but not installed. Optionnal for manually update.

ElectricSquid

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.

Juo

Just installed on SMF 2.0 RC1.2, works a treat. Thanks :)

ElectricSquid

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.

kai920

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!

LHW



kai920

Any one have any ideas about my issue? (2 posts up)

HR

#78
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 ;)

I can explain this as simply as possible.. If I do it & implement I guarantee it.
If I do it and you implement it its a crap shoot.

HR

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.

I can explain this as simply as possible.. If I do it & implement I guarantee it.
If I do it and you implement it its a crap shoot.

Advertisement: