Calling the Brain Trust

Ok, here is the situation. I have a website which has two virtual hostnames pointed at it – and They both point to the exact same location in the file system and serve the same content. However I need one of them to invoke a http authentication and the other not to.

The obvious solutions I see are…

Set up a rule in the .htaccess so it only requires a valid user when accessing the sub domain. This is the simplest solution but I don’t think such a rule exists.

Dynamically serve different .htaccess files based on the host being accessed. This ticks neither box of being simple or actually something you can actually make the computer do. But maybe it is if you start layering your .htaccess files.

Invoke the http authentication from the PHP script itself, detecting the server name and serving if appropriate. This is doable and straight forward to implement but requires quite a bit of coding.

Also maybe I can do the original solution, but only inside the vhosts.conf file? I haven’t really looked into that so that’s just speculation. Question is, which is the easiest solution to implement?



Don't have time to check my blog? Get a weekly email with all the new posts. This is my personal blog, so obviously it is 100% spam free.


Tags: , , ,

This entry was posted on Monday, May 31st, 2010 at 12:15 pm and is filed under Tech. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.