.htaccess: how to restrict access to a single file by IP?

前端 未结 4 805
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 07:55

I\'ve look all over, but keeps running into same info that talks about directory level IP restriction, which usually looks something like this:

Order Deny,A         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-01 08:51

    Mod-rewrite based solution :

    RewriteEngine on
    
    RewriteCond %{REMOTE_ADDR} !^Y\.O\.U\.R\.IP$
    RewriteRule ^file\.php$ - [F,L]
    

    The rewriteRule above will deny all requests to file.php if client ip does not match the ip address in the RewriteCond's pattern

提交回复
热议问题