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
Post a Comment