Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

How do I write the htaccess so that it will only require authentication when on, but not on (like by using some if-else clause)?

Background: I have a site running in two modes: The admin mode should be reached at something like, whereas the normal mode would be -- but both should point to the same directory & scripts within them (the scripts then turn on certain editing features by checking if the script is accessed from the admin subdomain).

Edit: I can now see this has been asked and answered at StackOverflow, though I can't get the top answer to work for me...

share|improve this question


  • that all the needed modules are installed
  • that all the directives can be used in .htaccess files.
  • The needed allowoverride settings are in the httpd.conf for the server to allow the use of .htaccess files
share|improve this answer

Try setting up a virtual host for the admin interface and adding the authentication configuration to a Location section inside it. Or just configure it for the whole virtual host.

share|improve this answer

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.