I'm struggling with the following issue.
My goal is to deny all connections to my site except for a couple of IPs. This is what I have in my .htaccess file.
order deny,allow
deny from all
allow from **.***.**.*** #person1
allow from **.***.**.*** #person2
# For Redirection
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ site/index.php?/$1 [L]
This was working just fine until I installed SSL with CloudFlare. The client IPs are now showing with a comma.
g.e. The hosting access logs and $_SERVER['REMOTE_ADDR'] show as 12.123.12.123,
(see the comma at the end).
So since then, the .htaccess
file is not validating correctly.
Does anybody know how to validate this situations? I'm not so familiar with Apache.
Thanks in advance!
What I have tried and don't work
allow from **.***.**.***/1
allow from **.***.**.***,
SOLUTION
Yey! Found the solution faster than expected. This is what worked for me.
order deny,allow
deny from all
SetEnvIF X-Forwarded-For "**.***.***.***" AllowIP #person1
SetEnvIF X-Forwarded-For "**.***.***.***" AllowIP #person2
Allow from env=AllowIP