Use HTTP Auth only if accessing a specific domain

前端 未结 5 1436
青春惊慌失措
青春惊慌失措 2020-12-30 06:02

I\'ve got several sites: example.com, example1.com, and example2.com. All of them point to my server\'s /public_html fo

5条回答
  •  猫巷女王i
    2020-12-30 06:59

    Here is one recommendation:

    Create a file called common.conf and save in an accessible location

    In this file place the Apache configuration common to all sites (hosts).

    The remove the current single VirtualHost entry an replace with VirtualHost entries as follows:

    # These are the password protected hosts
    
    ServerName example.com
    ServerAlias example1.com
    
    Include /path-to-common-configuration/common.conf
    
    AuthType Basic
    AuthName "Password Required"
    AuthUserFile "/path/to/.htpasswd"
    Require valid-user
    
    
    # These are hosts not requiring authentication
    
    ServerName example2.com
    ServerAlias example3.com
    
    Include /path-to-common-configuration/common.conf
    
    
    

提交回复
热议问题