1

Is it posible to protect a website if the site was called by a given domain name?

e.g.

www.domain.com -> no password protection
www.domain.net -> password protection

Both of the URLs are routed to the same document root.

Marlon
  • 11
  • 2
  • 1
    I found this page: http://stackoverflow.com/questions/4068975/domain-name-specific-code-blocks-in-htaccess – SamK Oct 10 '11 at 14:07

1 Answers1

1

If you have multiple virtualhosts, you can add password protection to one and not the other via the following directive:

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example1.org
<Directory "/www/example1">
AuthType Basic
AuthName "Protected Site"
AuthUserFile /etc/httpd/passwd
Require user joeuser
</Directory>
</VirtualHost>

Here is more information on this:

http://httpd.apache.org/docs/2.0/howto/auth.html

Rilindo
  • 5,058
  • 5
  • 26
  • 46