[英]Using htaccess block access to a range of URLs except for my IP address
我如何才能為除我的IP地址之外的所有地址屏蔽范圍或URL。
所以...
允許所有用戶使用http://mydomain.com/ *
除了我的IP以外,將http://mydomain.com/thisdirectoryandallcontents/ *禁止所有
我從另一個站點找到了一些可能有效的代碼,但是我沒有htaccess的技能來適應它
Options +FollowSymlinks
RewriteEngine on
#urls to exclude
RewriteCond %{REQUEST_URI} !/url-to-exclude-1$
RewriteCond %{REQUEST_URI} !/url-to-exclude-2$
RewriteCond %{REQUEST_URI} !^/images$
RewriteCond %{REQUEST_URI} !^/css$
RewriteCond %{REQUEST_URI} !^/$
#ip to allow access
RewriteCond %{REMOTE_HOST} !^11\.11\.11\.11$
#send to root
RewriteRule .? /http://www.mydomain.com [R=302,L]
我有類似的要求,並且在將我的頁面(或部分)進行維護時,基本上也要執行相同的操作。 htaccess文件的內容如下所示:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} /thisdirectoryandallcontents
RewriteCond %{REMOTE_ADDR} !=111.111.111.111
RewriteRule ^.*$ /maintenance.php [R=302,L]
我會根據您的要求逐步說明:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.