Jump to content

[SOLVED] IF Statements in .htaccess


rhodesa

Recommended Posts

Heys guys, as a developer I'll usually have a local copy of a site I'm working on and then the copy that is in production. Since the environments are different, sometimes they need to be slightly different (paths usually). I'm all set on doing conditionals in the PHP code of the site, but I can't figure out how to do conditionals for Apache Configs. For instance, if I am using HTTP Basic Auth, on my local system the line might look like:

AuthUserFile /usr/local/apache/passwd/passwords

while on my production server it might be:

AuthUserFile /home/useracct/hostname.com/passwords

Is there a way to test the HOST or SERVER name to determine which line to use dynamically?

Link to comment
Share on other sites

well...just to let everyone know...

 

i couldn't find anything designed for it, but i was able to work around it by using <IfModule>. i compared the list of loaded modules between the two servers and found a module that was on one but not the other. then, i used this:

AuthType Basic
AuthName "Protected"
Require valid-user

<IfModule prefork.c>
#Mini
AuthUserFile /www/websites/foobar/admin/.htpasswd
</IfModule>
<IfModule !prefork.c>
#arhodes
AuthUserFile "C:\webserver\eclipse_ws\foobar\admin\.htpasswd"
</IfModule>

 

not what it was designed for...but it works :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.