简体   繁体   English

禁止通过htaccess访问文件

[英]disallowing access to a file via htaccess

I have a page running on phpbb where I want to disable registrations from certain counteries. 我有一个在phpbb上运行的页面,我想在其中禁用某些计数器的注册。 I've ended up with this 我已经结束了

<Files "ucp.php">
Order Allow,Deny
Allow from all
SetEnvIf GEOIP_COUNTRY_CODE {country} BlockCountry
Deny from env=BlockCountry
</Files>

as you can see I'm using geoip to detect the country. 如您所见,我正在使用geoip来检测国家。 But now the problem is that this piece of code disallows already registered users to login from those countries, but I want just the registration part which is ucp.php?mode=register . 但是现在的问题是,这段代码不允许已经注册的用户从那些国家/地区登录,但是我只想要ucp.php?mode = register的注册部分。 This however doesn't work even with backslashes so I don't know how make it work. 但是,即使使用反斜杠也无法使用,所以我不知道它是如何工作的。

Thanks for your help 谢谢你的帮助

You could do something like this in your .htaccess 您可以在.htaccess中执行类似的操作

RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(CA|US|MX)$
RewriteCond %{QUERY_STRING} ^(.*)mode=register(.*)$ [NC]
RewriteRule ^ucp.php$ deny_page_for_other_countries.php  [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM