Apache: keep track of non-404 errors (e.g., 403, 500, et al)

Apache: keep track of non-404 errors (e.g., 403, 500, et al) - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about php, htaccess, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


In cpanel I always have the error log open ("This function will display the last 300 errors for your site.") which is nice for 404's but what about the rest?



I'm working on a few things in htaccess, such as this:



RedirectMatch 403 /($|*)/?$


So now when I try any URL with a dollar-sign or an asterisk in it, bam, 403 forbidden; perfect.



So I refresh cpanel's error log page, and nothing. It seems to only care about 404's.



Incidentally, httpd.conf, which I cannot alter, is setup this way:



CustomLog "logs/access_log" common


The errors I'd like to know how to monitor are: 400, 401, 403, and 500.


Solution :

The Apache error log does track errors other than 404 errors. In the case of 500 errors, it shows you any error output from your scripts. cPanel must be hiding this information from you.



I usually filter the access logs to see a single line for each error page that occurs. I tend to use the command line to tail and filter it like this:



tail -F /var/log/apache2/access_log | grep -E '" (404|403|500) '

Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect