views:

15

answers:

1

I am using the same .htaccess file on my local, and live servers, and want to 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.

A: 

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.

Till
Thanks, however that still means maintaining the htaccess in 2 places. There's no way to have 2 htaccess files acting? So one can be the "master" with the main info, and a second one to "add on" the AuthType?
Newmania
I extended my answer, hope it helps.
Till