Error for customize page error 500

5.1k Views Asked by At

I dont know why i cant customize error 500 but its good for 404, 403

I have folder like that

  • www
    • index.php
    • .htaccess (2)
  • error
    • index.php
  • .htaccess (1)

the first htaccess

RewriteEngine on
RewriteBase /

# Error
ErrorDocument 403 /error/index.php?error=403
ErrorDocument 404 /error/index.php?error=404
ErrorDocument 500 /error/index.php?error=500

And second

RewriteEngine on
RewriteBase /
RewriteRule ^(.+)/$ /www/index.php?v=$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /www/index.php?v=$1 [QSA,L]

Thanks

1

There are 1 best solutions below

0
On BEST ANSWER

Customized Error 500 pages are the hardest to use. The problem is, there are many reasons why a server can throw a 500 internal server error. Custom pages for 500 only work if the cause of the 500 can be handled by Apache to display the page. Say for instance you made a syntax error in your .htaccess page or in your apache config file, it's going to throw a 500 server error but because Apache is down, it can't serve anything including that custom page, so you get the browsers default page. Also depending on how you have your PHP error reporting setting you won't get 500 custom page either. There is a lot more to this and customizing 500 page is almost useless cause most people won't ever see that. You will know before they will because it's a 500 is typically configuration issue, like a syntax error in your code.

503 is the most common page a user will see especially if your site is down for maintenance and those are the one's I would focus on.

Anyway, I'd take a look at this link to see more info on 500 custom pages on when and why it won't work.

Apache's ErrorDocument directive does not redirect.

Also from Apache docs

Although most error messages can be overridden, there are certain circumstances where the internal messages are used regardless of the setting of ErrorDocument. In particular, if a malformed request is detected, normal request processing will be immediately halted and the internal error message returned. This is necessary to guard against security problems caused by bad requests.

http://httpd.apache.org/docs/2.4/mod/core.html#errordocument