Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<IfModule mod_rewrite.c>
    RewriteEngine On
    	RewriteCond %{HTTP_USER_AGENT} !Mozilla^([^\/]+)\/(\d+)\.(\d+)[^\(]+\(([^\;]+)[^\)]+\) [NC]
    RewriteRule ^ - [F]
</IfModule>

...

Code Block
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} !Mozilla^([^\/]+)\/(\d+)\.(\d+)[^\(]+\(([^\;]+)[^\)]+\) [NC]
RewriteRule ^ - [F]


How do I block in my php code?

...

Code Block
# block abnormal connection
if (!preg_match("/^Mozilla([^\/]+)\/(\d+).(\d+)[^\(]+\(([^\;]+)[^\)]+\)/", getenv('HTTP_USER_AGENT')))
 {
	http_response_code(404);
	exit;
}

...