Htaccess <Directory> disable all
Recently, I clean my project. I have a main .htaccess in the root directory and 6 more others. 5 of them performed Options -Indexes , and I did not see any point allow any directory browsing to move so that the main one. so now i have only 2 .htaccess files. main and one in /system , which contains
# Block External Access deny from all So, I wanted to run this on /system only from the main one. So I deleted one in / system and added
# Block External Access <Directory "/system/"> deny from all </Directory> to my main .htaccess file leaving 1!
but now i get
Internal Server Error
The server detected an internal error or an incorrect configuration and your request failed.
Contact your server administrator, webmaster @localhost, and let them know when the error occurred, and anything else that could lead to an error.
Additional information about this error may be available if a server error occurs.
Apache / 2.2.17 (Ubuntu) Server on 10.0.1.5 Port 80
The goal is to block the reading of any files in / system and its subdirectory, but to allow viewing of the rest from a single .htaccess file for the entire project. Any ideas on how I can fix this? I did some Google searches, but really couldn’t find anything.
You cannot use the Directory Directive in .htaccess. However, if you create a .htaccess file in the / system directory and put the following in it, you will get the same result
#place this in /system/.htaccess as you had before deny from all You can also use the RedirectMatch directive to restrict access to the folder.
To deny access to a folder, you can use the following RedirectMatch command in htaccess:
RedirectMatch 403 ^/folder/?$ This will prevent external access to / folder / for example: http://example.com/folder/ will return a 403 forbidden error.
To deny access to everything inside the folder, you can use this:
RedirectMatch 403 ^/folder/.*$ This will block access to the entire folder, for example: http://example.com/folder/anyURI will return a 403 error response to the client.
You can use from the root directory:
RewriteEngine On RewriteRule ^(?:system)\b.* /403.html Or:
RewriteRule ^(?:system)\b.* /403.php # with header('HTTP/1.0 403 Forbidden');