0

是否可以使用 htpasswd 或某种 htaccess 规则来保护特定端口号。例如,我在端口 5533 上运行了数据库分析器,并希望阻止公众访问它。

谢谢

4

1 回答 1

1

试试这个:

    RewriteCond %{SERVER_PORT} !5533 # If port is 5533
    RewriteRule ^ - [E=NO_AUTH:1] # We're setting the env variable for any request
                                  # because condition works only on next line

    Order deny,allow 
    Deny from all
    AuthType basic
    AuthName "You have to be logged in"
    AuthUserFile "/etc/httpd/conf.d/.htpasswd" #Your htpasswd path
    Require valid-user
    Allow from           env=NO_AUTH # If env variable was set
                                     # we can pass the request only through authentication
    Satisfy              Any
于 2013-01-02T11:32:35.830 回答