How would you white-list countrys?

Indrek

New Member
#1
Hi

I would like to use white-list to block most of the countries on some of my websites.

On apache I would use cloudflare and .htaccess for this. I'm sure this can be done on OLS too but I couldn't get it working.

.htaccess on apache:
Code:
<FilesMatch "wp-login.php">
RewriteEngine on
RewriteCond %{HTTP:CF-IPCOUNTRY} !^(US|CA)$
RewriteRule ^ - [F,L]
</FilesMatch>
original link

That would block everything except US and CA.
I tried to modify it for OLS but couldn't get it working.

Any ideas?
 
#2
Hi

I would like to use white-list to block most of the countries on some of my websites.

On apache I would use cloudflare and .htaccess for this. I'm sure this can be done on OLS too but I couldn't get it working.

.htaccess on apache:
Code:
<FilesMatch "wp-login.php">
RewriteEngine on
RewriteCond %{HTTP:CF-IPCOUNTRY} !^(US|CA)$
RewriteRule ^ - [F,L]
</FilesMatch>
original link

That would block everything except US and CA.
I tried to modify it for OLS but couldn't get it working.

Any ideas?
Just throwing this out, did you try activate Rewrite and just add
Code:
RewriteCond %{HTTP:CF-IPCOUNTRY} !^(US|CA)$
RewriteRule ^ - [F,L]
in rewrite-section ?
 

Indrek

New Member
#3
Hey

Code:
RewriteCond %{HTTP:CF-IPCOUNTRY} !^(US)$
RewriteRule ^ - [F,L]
That works perfectly. But i'm trying to block just the registration .php page for other countries.
 
#5
Hi Indrek,

Try something like this:
Code:
RewriteCond %{HTTP:CF-IPCOUNTRY} !^(US|CA)$
RewriteRule wp-login.php$ - [F,L]
 

Indrek

New Member
#6
I tried it like this

Code:
RewriteCond %{HTTP:CF-IPCOUNTRY} !^(US)$
RewriteRule member.php - [F,L]
Without the $ and it works.
Doesn't work with the $
:s
 
#7
If you go to wherever you added the rules and set the rewrite logging to 9 and restart the server, it should explain how it fails, what it tried to match.

The $ is used to mean "ends with", so using my rule as an example, it means "ends with wp-login.php"
 
Top