I am using the same .htaccess file on my local, and live servers, and want t开发者_运维百科o use the same file on my test server (to made code management easier).
Currently though I have to have a different file, because my test server has htaccess password access on it, AuthType Basic.
Is there a way to either have 2 .htaccess files in the same folder (different names of course) - so that I can add the extra file on the test server, or, somehow make the AuthType conditional based on where it is, ie in a certain folder or under a certain http host? This way the same file can be used but it will act differently depending on where you are viewing it from.
Help and advice much appreciated.
One way would be to configure a different AccessFileName
on the development server, e.g. htaccess.dev
.
In httpd.conf
(or similar - depending on your distro):
AccessFileName htaccess.dev
Then add both files in the directory - the htaccess.dev
should be only interpreted on the development server.
You can also set AccessFileName
per <VirtualHost />
.
There are a way to do multiple AccessFileName
directives:
AccessFileName .htaccess.first .htaccess.second .htaccess
I'm not exactly sure which is parsed first, but I imagine the last one wins, meaning it's probably .first
, .second
and then .htaccess
and whatever is in the last one is the active setting.
精彩评论