![]() |
.htaccess password protect for a specific domain - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: .htaccess password protect for a specific domain (/showthread.php?tid=28657) |
.htaccess password protect for a specific domain - El Forum - 03-17-2010 [eluser]CroNiX[/eluser] For a project, I have www.mydomain.com and dev.mydomain.com and I want to use a single htaccess file that will work for both of them, but I want password protection for the dev site. This is so we can use a single .htaccess file in git. if(site_url === 'dev.mydomain.com') { AuthType basic AuthName "Development" AuthUserFile /home/path/.htpasswd Require valid-user } how would you write that in .htaccess? Thanks .htaccess password protect for a specific domain - El Forum - 03-17-2010 [eluser]bretticus[/eluser] Do... www.mydomain.com and dev.mydomain.com ...point to the same directory and/or virtual host? If they do then you probably can't do this with an htaccess file (at least I know of no way to do a conditional that is a directive allowing host header matching.) Instead, you could detect this in your application and generate the appropriate auth headers via code: http://php.net/manual/en/features.http-auth.php .htaccess password protect for a specific domain - El Forum - 03-17-2010 [eluser]CroNiX[/eluser] they are actually independent virtual servers, but share a common git repository. Thanks for the PHP reference, I didn't even think to check that side of it lol. .htaccess password protect for a specific domain - El Forum - 03-17-2010 [eluser]bretticus[/eluser] [quote author="CroNiX" date="1268892936"]they are actually independent virtual servers, but share a common git repository.[/quote] In that case, if you have access to the apache config files (httpd.conf. etc.) than just do the auth configuration for one. .htaccess password protect for a specific domain - El Forum - 03-17-2010 [eluser]CroNiX[/eluser] Why do you have to make me feel soooo stupid today lol. Oh man, one of those days... .htaccess password protect for a specific domain - El Forum - 03-17-2010 [eluser]bretticus[/eluser] [quote author="CroNiX" date="1268903395"]Why do you have to make me feel soooo stupid today lol. Oh man, one of those days...[/quote] Well, not too many developers administer Web servers and write code. Fortunately, I'm one of the unfortunate. ![]() ![]() |