Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know in a VirtualHost definition I can have:

    AccessFileName .myfilename

However, apache does not allow this:

    AccessFileName /absolute/location/of/.myfilename

Is there some sort of a workaround? I want to have one directory which is used with multiple sites, but I would like to have different .htaccess files with rules on a per-site basis.

I know I can set the rules in the VirtualHost definition, but that requires restarting / reloading apache each time I make changes.

I realize I could have different file names for each site, but I was trying to keep from cluttering up the directory.

Is there a good way to do this?

share|improve this question
up vote 4 down vote accepted

No absolute paths, as the access file is always checked for in parent paths.

The example provided in the documentation:

AccessFileName .acl

before returning the document /usr/local/web/index.html, the server will read /.acl, /usr/.acl, /usr/local/.acl and /usr/local/web/.acl for directives, unless they have been disabled with AllowOverride None

You want them on a per-site basis - unless the sites share their entire directory structure, then you can just put them in each site's path. But, I'd recommend just reloading when the config changes.

In the immortal words of Apache's documentation: "In general, you should never use .htaccess files unless you don't have access to the main server configuration file."

share|improve this answer
Great info - thanks. I didn't think about the cascading permissions. I also agree with the security concerns, but this is for a development server and so having the rules in the files makes them a lot easier to change on the fly. – cwd Sep 1 '11 at 18:53
@cwd Performance is the other major concern; the file's re-read (after checking the entire directory structure again) for every resource requested. service apache2 reload isn't that bad, I swear! ;) – Shane Madden Sep 1 '11 at 18:55
Good call. I have an alias set up for reloading with just a few keystrokes, but it still adds an extra step in when developing and testing rules :) – cwd Sep 1 '11 at 18:57
Then write yourself a script that automatically reloads on a change? Perhaps using inotify or something like that? – Zoredache Sep 1 '11 at 21:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.