我想添加一个htaccess来允许来自特定ip的访问。
这棵树是这样的
domain
/abc/
/def/我想限制文件夹/abc/,但是白名单文件夹/def/
而且,在/abc/上有一个名为ghi.php的特定文件。我能允许访问那个特定的文件吗?
我该怎么做?
这就是我在/abc/中的内容,它重定向每个没有进入指定ip的人。但是,我希望允许访问该dir中的ghi.php。
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^125\.17\.119\.16$
RewriteRule ^ http://www.domain.com/ [R]发布于 2016-06-07 19:39:20
试着:
RewriteEngine on
#Allow access to the file
RewriteRule ^abc/ghi\.php$ - [L]
#forbid the request for /abc/* if ip not=1.2.3.4.5
RewriteCond %{REMOTE_ADDR} !^1\.2\.3\.4\.5$
RewriteRule ^abc - [F,L]如果您想将请求重定向到主页,只需更改行
RewriteRule ^abc - [F,L]至
RewriteRule ^abc http://example.com/ [L,R]发布于 2016-06-07 21:07:21
我不会将mod_rewrite用于内容保护,而是使用为此创建的模块:
# Default: deny all
Order Allow,Deny
# Allow the IP for everything
Allow from 125.17.119.16
# Allow access to this one PHP file
<Files /abc/ghi.php>
Allow from all
</Files>
# Allow access to everything inside that folder
<FilesMatch "^/def/">
Allow from all
</FilesMatch>https://stackoverflow.com/questions/37687710
复制相似问题