.htacess Configuration - Dynamic Error Page

1

I would like to know if it is possible to generate a dynamic error page from the parameters passed to an html page and take these parameters through a javascript code? Or in any other way you do not need to create a page for each error.

Example:

ErrorDocument 400 /error.html?400
ErrorDocument 401 /error.html?401
ErrorDocument 403 /error.html?403
ErrorDocument 404 /error.html?404
ErrorDocument 500 /error.html?500
    
asked by anonymous 17.06.2016 / 16:07

1 answer

0

This is very simple, you can do as follows:

ErrorDocument 403 /403.php
RewriteRule ^403.php$ erros.php?tipo=403 [L,QSA]

ErrorDocument 404 /404.php
RewriteRule ^404.php$ erros.php?tipo=404 [L,QSA]

ErrorDocument 500 /500.php
RewriteRule ^500.php$ erros.php?tipo=500 [L,QSA]

And so it goes ..

The 404.php, 500.php, etc. files do not need to exist physically. The .htaccess will handle them automatically and redirect as you want.

In the errors.php file (for example), you treat the type of error with $ _GET ['type'] and send the desired message.

This article explains a bit more about how to work with the error pages on the server.

    
19.06.2016 / 07:04