{"id":11322,"date":"2021-12-09T01:05:52","date_gmt":"2021-12-09T06:05:52","guid":{"rendered":"http:\/\/local.brightwhiz\/?p=11322"},"modified":"2021-12-09T01:05:54","modified_gmt":"2021-12-09T06:05:54","slug":"errordocument-404-vs-fallbackresource-apache-htaccess","status":"publish","type":"post","link":"http:\/\/local.brightwhiz\/errordocument-404-vs-fallbackresource-apache-htaccess\/","title":{"rendered":"ErrorDocument 404 vs FallbackResource in Apache .htaccess on Ubuntu"},"content":{"rendered":"\n
As we discuss the debate of ErrorDocument 404 vs FallbackResource in Apache, it is good to note that Apache<\/a> provides the ErrorDocument directive to help you catch all types of error responses. When caught the server can redirect to a more friendly URL.<\/p>\n\n\n\n The directive works by specifying the HTTP status code to catch and the URL to rewrite to. If you want to catch all 500 error responses, add the following line to your .htaccess file. The instructions here work on Mac, Windows<\/a>, and Linux<\/a> systems such as Ubuntu<\/a>, CentOS, Debian, RHEL, and others.<\/p>\n\n\n\n The ErrorDocument directive associates each type of error can be set within the virtual host that is currently defined. The only difference here is that you have to reload or restart the Apache server to apply changes<\/p>\n\n\n\n or<\/p>\n\n\n\n In Apache, you can use the FallbackResource directive to set a handler for any URL that doesn’t map to anything in your filesystem, and would otherwise return HTTP 404 (Not Found). This will cause requests for non-existent files to be handled by the file specified in the directive. Both of these directives behave similarly only that in the case of FallbackResource you do not specify the HTTP status code. The other difference is FallbackResource will not log an entry in the error logs that way you do not have to be concerned about your error logs growing too unnecessarily large.<\/p>\n","protected":false},"excerpt":{"rendered":" As we discuss the debate of ErrorDocument 404 vs FallbackResource in Apache, it is good to note that Apache provides the ErrorDocument directive to help you catch all types of…<\/p>\n","protected":false},"author":1,"featured_media":11324,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,25,27,16],"tags":[58,121,183,350,354,359,424,433,449,471,526,591,598,646],"yoast_head":"\nErrorDocument 500 \/error-500.html<\/code><\/pre>\n\n\n\n
ErrorDocument in Apache Server or VirtualHost Config<\/h2>\n\n\n\n
$ sudo systemctl reload apache2<\/code><\/pre>\n\n\n\n
$ sudo service apache2 reload<\/code><\/pre>\n\n\n\n
So, What About FallbackResource Directive?<\/h2>\n\n\n\n
Here’s an example:<\/p>\n\n\n\nFallbackResource \/notfound-404.php<\/code><\/pre>\n\n\n\n
ErrorDocument 404 vs FallbackResource<\/h2>\n\n\n\n