.htaccess in Multiple Environments

前端 未结 2 1176
北恋
北恋 2021-02-13 13:21

I know similar questions have been asked before but I haven\'t found any really specific answers for my situation.

I have an ExpressionEngine site running on multiple en

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-13 13:28

    Jon's answer is a good one. Unfortunately, not all web hosts will allow you to control that -D parameter for starting Apache.

    Here's a way to use a single htaccess file on dev and production, but only have the dev site password protected:

    # ----------------------------------------------------------------------
    # Password protect staging server
    # Use one .htaccess file across multiple environments
    # (e.g. local, dev, staging, production)
    # but only password protect a specific environment.
    # ----------------------------------------------------------------------
    
    SetEnvIf Host staging.domain.com passreq
    AuthType Basic
    AuthName "Password Required"
    AuthUserFile /full/path/to/.htpasswd
    Require valid-user
    Order allow,deny
    Allow from all
    Deny from env=passreq
    Satisfy any
    

提交回复
热议问题