2012-03-26 93 views
1

我希望某些范围的ips(Canada Country Block IPS)只能在我的登录页面(http://www.mysite.com/)中使用POST方法index.php?m = account_login)和我的注册页面 (http://www.mysite.com/index.php?m=account_register) 但是我想让所有ips访问我的主站点http://www.mysite.com/index.php并能够请使用POST方法,例如我们的联系页面 (http://www.mysite.com/index.php?m=contactus).htaccess允许POST方法仅用于cetain IP范围

谢谢。

<Limit GET POST> 
order deny,allow 
# Country: CANADA 
# ISO Code: CA 
# Total Networks: 6,365 
# Total Subnets: 79,978,496 
allow from 23.16.0.0/16 
allow from 23.17.0.0/16 
allow from 24.36.0.0/16 
allow from 24.37.0.0/16 
... 
allow from 192.197.216.0/24 
allow from 216.254.192.0/19 
# 
deny from all 
</Limit> 

回答

1

还有就是要实现这个没有笔直的路,但我和小窍门这样做我自己:-D Limit只检查请求的方法,所以没有办法检查文件或URL。解决方案是使用FilesMatch指令。但在这里,我们有一个问题,像我有:查询字符串:-( 解决方案这一个是使用RewriteRule

重写规则的login.html的index.php M = account_login [L,QSA] 重写规则寄存器? ?的.html的index.php M = account_register [L,QSA]

现在,我们拥有一切我们想要的:

<FilesMatch "(login|register)\.html$"> 
    <Limit GET POST> 
     order deny,allow 
     # Country: CANADA 
     # ISO Code: CA 
     # Total Networks: 6,365 
     # Total Subnets: 79,978,496 
      allow from 23.16.0.0/16 
      allow from 23.17.0.0/16 
      allow from 24.36.0.0/16 
      allow from 24.37.0.0/16 
      allow from 192.197.216.0/24 
      allow from 216.254.192.0/19 

      deny from all 
    </Limit> 
</FilesMatch> 

RewriteRule (register|login)\.html  index.php?m=account_$1&allow=yes [L,QSA] 
RewriteCond %{QUERY_STRING}  m=account_(register|login) 
RewriteCond %{QUERY_STRING} !allow=yes 
RewriteRule index\.php - [F,L] 

我喜欢或注册,以避免RewriteRule s到创建记录新文件