Would this .htaccess alone cause 404 and 500 errors?

Would this .htaccess alone cause 404 and 500 errors? - .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 htaccess, 404, cpanel, http-code-500, .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 :


My site is down and depending on what I change I get a 500 error or a 404 or a "Forbidden you are not authorized" error. In checking my .htaccess files I found a strange one:



<IfModule !mod_authz_core.c>
Order deny,allow
Deny from all
</IfModule>
<IfModule mod_authz_core.c>
Require all denied
</IfModule>


Would "Deny from all" and "Require all denied" be the reason my site is down? It seems like this would be the cause, right?


Solution :


I get a 500 error or a 404 or a "Forbidden you are not authorized" error.




The code you posted should result in a 403 Forbidden for all visitors. The first <IfModule> block applies to Apache 2.2 (and below) and the second block applies to Apache 2.4+ (strictly Apache 2.3+). Although the first block alone would "work" on both Apache 2.2 and 2.4 if you removed the <IfModule> wrapper.



I say "should", because, whatever error document is being served when the 403 is triggered could change the HTTP status to something else. Sometimes a 404 might be preferable to a 403 and sometimes the server is simply misconfigured.



You also shouldn't be getting different errors with the same block of code.




Would "Deny from all" and "Require all denied" be the reason my site is down?




If that is the only code in your .htaccess file then yes, that would certainly be one big reason! However, that code is quite deliberate and looks a bit dubious since it is specifically targeting multiple server versions.




...depending on what I change




What things were you changing?


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