2013-01-02 197 views
0

是否可以使用htpasswd或某種htaccess規則來保護特定的端口號。例如,我有端口5533上運行的數據庫分析器,並希望阻止公衆訪問它。端口號htpasswd

感謝

回答

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 
+0

您好,感謝。你能爲我解釋一下你的規則嗎?當談到htaccess時,我有點兒是初學者 – outrunthewolf