News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Add an Apache Error Handler to SMF

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

Previous topic - Next topic

sshahnawaz

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...  :)
How to Make Money Online - Urdu Description https://www.youtube.com/watch?v=0Deggh2ZxNE

Sabre™

Edit the ApacheError.template.php and add your text to your Modifications.english.php
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


sshahnawaz

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?
How to Make Money Online - Urdu Description https://www.youtube.com/watch?v=0Deggh2ZxNE

Sabre™

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 :)
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


sshahnawaz

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.   :)
How to Make Money Online - Urdu Description https://www.youtube.com/watch?v=0Deggh2ZxNE

Afro

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 ?

carderne

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.

Cap. Price

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ón Errónea';
$txt['apache_err_400_dsc'] = 'La solicitud contiene sintaxis errónea y no debería repetirse.';
$txt['apache_err_401_msg'] = 'Error 401 - No Autorizado';
$txt['apache_err_401_dsc'] = 'No tiene autorización para acceder a esta página.';
$txt['apache_err_402_msg'] = 'Error 402 - Pago Requerido';
$txt['apache_err_402_dsc'] = 'Codigo de error nú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ágina o directorio.';
$txt['apache_err_404_msg'] = 'Error 404 - No Encontrado';
$txt['apache_err_404_dsc'] = 'No se encontró la página. Puede que la página solicitada ya no exista, haya cambiado de nombre o no esté disponible temporalmente.';
$txt['apache_err_405_msg'] = 'Error 405 - Método no Permitido';
$txt['apache_err_405_dsc'] = 'Una petición fue hecha a una URI utilizando un mé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ón Proxy Requerida';
$txt['apache_err_407_dsc'] = 'Debe autenticar con un servidor proxy antes de atender esta solicitud. Inicie sesión en el servidor proxy e inténtelo de nuevo.';
$txt['apache_err_408_msg'] = 'Error 408 - Tiempo de Espera Agotado';
$txt['apache_err_408_dsc'] = 'Su navegador o su conexión a fallado al intentar abrir la página solicitada. Inté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á disponible en el servidor y ninguna dirección que se remite es conocida. Esta condició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ón Previa Fallida';
$txt['apache_err_412_dsc'] = 'La condición previa cedida en uno o más de los campos del título de petición evaluó a falso cuando se probó en el servidor.';
$txt['apache_err_413_msg'] = 'Error 413 - Entidad de la Demanda Demasiado Grande';
$txt['apache_err_413_dsc'] = 'El servidor está negándose a procesar una demanda porque la entidad de la demanda es má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á negándose a procesar una demanda porque la URI especificada es má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á rechazando la demanda porque la entidad de la demanda está en un formato no apoyado por el recurso pedido para el mé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ó 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ó una condición inesperada que le impidió 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ó para cumplir la demanda.';
$txt['apache_err_502_msg'] = 'Error 502 - Entrada Errónea';
$txt['apache_err_502_dsc'] = 'El servidor, mientras actuaba como una gateway o proxy, recibió una contestación inválida desde el servidor del upstream y accedió 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ó una contestación oportuna del servidor upstream que accedió intentando completar la demanda.';
$txt['apache_err_505_msg'] = 'Error 505 - Versión de HTTP no Soportada';
$txt['apache_err_505_dsc'] = 'El servidor no soporta, o se niega a soportar, el protocolo de versión HTTP que se usó 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.';

¡Gort! ¡Klaatu barada nikto!

KensonPlays

Thanks! Helps with GoDaddy linux apache stuff!

Owner of Mesozoic Haven

luismanson

is anyone using this great mod with pretty urls? i see some people with problems and i dont wana risk my live forum :(

luismanson

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

Sabre™

Try [THIS] solution.
I have not tried it, but it seems to have worked for others.
Do NOT give admin and/or ftp details to just anybody, see if they are trust worthy first!!  Do your homework ;)


coolfx350

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.

dougiefresh

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!

Vutrox

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

KensonPlays


Owner of Mesozoic Haven

HR

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).

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.

Webdzr

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 hxxp:mysite.com/non_exist_page [nonactive] always redirects to the home page its only when the url is like hxxp:mysite.com/non_exist_page.php [nonactive] 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

bearstreet

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
Dont do drugs, coz if you get caught u will go to prison, and drugs are real expensive in prison
:P

Ask me Maths Questions

bearstreet

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
Dont do drugs, coz if you get caught u will go to prison, and drugs are real expensive in prison
:P

Ask me Maths Questions

Advertisement: