Home > Blockchain >  Apache - how to define an exception with REMOTE_HOST?
Apache - how to define an exception with REMOTE_HOST?

Time:08-02

Require not ip

and

RewriteCond %{REMOTE_ADDR}

do not work reliable in my .htaccess.

This seems to lock out unwanted visitors better:

RewriteCond %{REMOTE_HOST} (sta\.81\.106\.9\.x\.client\.server\.de) [NC,OR]
RewriteCond %{REMOTE_HOST} (sta\.83\.94\.46\.xx\.client\.server\.de) [NC,OR]
RewriteCond %{REMOTE_HOST} (sta\.106\.51\.63\.xxx\.client\.server\.de) [NC,OR]
#...and more of these guys ...
RewriteRule .* - [F,L]

But I do not want to lock out this:

sta.106.51.64.yyy.client.server.de (corresponding to ip IP 88.198.yy.zzz)

How can I define this exception in my .htaccess ?

CodePudding user response:

With your shown samples and attempts please try following htacces rules. We can put combine conditions and then accordingly block the requests from users.

You could check logs after applying these to see how system is behaving too.

RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)?.*\.client\.server\.de$ [NC]
RewriteCond %{HTTP_HOST} !^(?:www\.)?sta\.106\.51\.64\.yyy\.client\.server\.de$ [NC]
RewriteRule ^ - [F,L]
  • Related