2
如何配置這在我的Apache/htaccess的配置:htaccess的:條件認證
我想HTTP的身份驗證有一個例外的所有文件。 可以從1.2.3.4訪問文件click.php
和js/clickheat.js
而無需任何身份驗證。
我試過FilesMatch,但是我不能倒置它。所以我不能把require valid-user
放在那裏。我以爲使用SetEnv
,但我如何檢查它呢?
<FilesMatch "(click\.php|clickheat\.js)">
# what here?
</FilesMatch>
我的另一個想法是使用mod_rewrite。那麼,我可以允許從給定主機訪問這兩個文件,並從其他地方拒絕它。但我如何鏈接它與HTTP身份驗證?
# allows access to two files from the given IP
RewriteCond %{REMOTE_ADDR} 1\.2\.3\.4
RewriteCond %{REQUEST_URI} ^/click.php [OR]
RewriteCond %{REQUEST_URI} ^/js/clickheat\.js
RewriteRule (.*) - [L]
# denies everything else
RewriteRule (.*) - [F,L]
所以我最喜歡的解決方案是通過RewriteCond/RewriteRule啓用HTTP-Auth。
背景(或爲什麼我想這樣做):我試圖確保clickheat(http://www.labsmedia.com/clickheat/index.html)安裝。 1.2.3.4是遠程運行的mod_proxy並將其訪問權重定向到我們的clickheat主機。