Search code examples
php.htaccessphpbb

disallowing access to a file via htaccess


I have a page running on phpbb where I want to disable registrations from certain counteries. 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. 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. This however doesn't work even with backslashes so I don't know how make it work.

Thanks for your help


Solution

  • You could do something like this in your .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]