Forum Moderators: phranque

Message Too Old, No Replies

disable .htaccess for some sub-directories

Is there any way to specify which directories cannot use .htaccess files u

         

epsd

5:17 pm on Aug 21, 2007 (gmt 0)

10+ Year Member



In my public website, I have .htaccess enabled to do redirects, etc. However, some of the sub-directories in my site are maintained by other people. These people (currently) can create their own .htaccess file for their subdirectory. However, I would like to disable this (but just from certain directories). Is there any way to specify which directories cannot use .htaccess files using httpd.conf? Any suggestions?

jdMorgan

6:08 pm on Aug 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can put AllowOverride [httpd.apache.org] directives inside <Directory [httpd.apache.org]> containers in httpd.conf, with the <Directory> containers specifying directories which can and/or cannot use .htaccess. Example:

# Default to allow all to use .htaccess
<Directory /*>
AllowOverride All
</Directory>
#
# Disable .htaccess in this path
<Directory /cannot/use/htaccess/*>
AllowOverride None
</Directory>
#
# But turn some features back on for this one dir in the above path
<Directory /cannot/use/htaccess/[b]but-this-one-can[/b]/*>
AllowOverride FileInfo Options
</Directory>

You can also use extended regular expressions using the "~" operator, or by using <DirectoryMatch>.

The processing of matches varies depending on what version of Apache you are using and can be quite complex, so read all the linked documentation very carefully. Also, if you're on Apache 1.x, try to keep the <Directory>-priority-structure very simple to minimize problems when you migrate to Apache 2.x

Note that you can allow users to set per-directory Options, or reserve Options configuration for the httpd.conf level, depending on how you set AllowOverride in httpd.conf. Be aware that the FollowSymLinks or SymLinksIfOwnerMatch Options must be enabled for users to be able to use mod_rewrite in .htaccess. Similarly, AllowOverride FileInfo is needed to allow users to define their own ErrorDocument(s) -- There are many combinations of AllowOverride and Options settings, so I cannot describe them all here.

Be sure you give your users absolutely everything they need to do what they want and need to do (but no more).

Jim