regex - How to block all accesses, except three IPs, to an absolute URL with htaccess? -


how block accesses, except 3 ips, absolute url htaccess?

example data: http://subdomain.example.com/url/i/want/to/block ips: 10.10.10.10 10.10.10.11 10.10.10.12

this code:

rewritecond %{request_uri} http://subdomain.example.com/url/i/want/to/block rewritecond %{remote_addr} !=10.10.10.10 rewritecond %{remote_addr} !=10.10.10.11 rewritecond %{remote_addr} !=10.10.10.12 rewriterule ^.*$ /index.php [r=302,l] 

and it's not working. i'm accessing url ip.

you can't match protocol , port etc in request_uri. have way:

rewritecond %{http_host} =subdomain.example.com rewritecond %{remote_addr} !=10.10.10.10 rewritecond %{remote_addr} !=10.10.10.11 rewritecond %{remote_addr} !=10.10.10.12 rewriterule ^url/i/want/to/block /index.php [r=302,l,nc] 

or using regex character class:

rewritecond %{http_host} =subdomain.example.com rewritecond %{remote_addr} !^10\.10\.10\.1[0-2]$ rewriterule ^url/i/want/to/block /index.php [r=302,l,nc] 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -