Settings . htacess - Dynamic Error Page

Asked

Viewed 63 times

1

I wonder if it is possible to generate a dynamic error page from parameters passed to an html page and get these parameters through a javascript code? Or any other way that you don’t 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
  • tries if this solves Options -Indexes, ai Voce only needs to have a way to catch with javascript and do the trickery... Errordocument 403 /folder/403.html? id=403 Errordocument 404 /folder/404.html? id=404

1 answer

0

That’s very simple, you can do it this way:

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 on and so on..

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

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

This article explains a little more about working with the error pages on the server.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.