來源于:
https://blog.wpjam.com/m/block-bad-queries/
下面代碼檢查下訪問的 URL 是否長度 < 255,是否有那與 “eval(” 或者 “base64”字符串,這些都是惡意 URL 請求的特征,不過貌似會和 Google Custom Search 有沖突。
<?php
/* Plugin Name: Block Bad Queries */
if (strlen($_SERVER['REQUEST_URI']) > 255 ||
strpos($_SERVER['REQUEST_URI'], "eval(") ||
strpos($_SERVER['REQUEST_URI'], "base64")) {
@header("HTTP/1.1 414 Request-URI Too Long");
@header("Status: 414 Request-URI Too Long");
@header("Connection: Close");
@exit;
} ?>
復(fù)制到主題的?functions.php
?即可。