WordPress技巧:防止WordPress遭受恶意的URL链接请求

前端之家收集整理的这篇文章主要介绍了WordPress技巧:防止WordPress遭受恶意的URL链接请求前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

站长朋友们在使用wordpress建站以后,当网站上线以后,经常会受到一些恶意侵害,有的是尝试破解后台密码的,有的是遭遇到恶意的URL链接请求。这篇wordpress教程里我们主要讲解一下如何让防止wordpress网站遭受恶意的URL链接请求。解决的思路是检查下访问的URL链接长度是否小于255,是否包含 “eval(”或者 “base64”字符串,这些都是一些恶意URL链接请求的特征,但是此方法可能会和Google Custom Search有冲突。

切换到主题目录,打开functions.PHP,输入以下代码

Crayon-5c891d17cea1a779063338" class="Crayon-Syntax Crayon-theme-classic Crayon-font-monaco Crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouSEOver" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
Crayon-toolbar" data-settings=" mouSEOver overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-title">functions.PHP
Crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">Crayon-mixed-highlight" title="Contains Mixed Languages">
Crayon-button Crayon-nums-button" title="Toggle Line Numbers">
Crayon-button-icon">
Crayon-button Crayon-plain-button" title="Toggle Plain Code">
Crayon-button-icon">
Crayon-button Crayon-wrap-button" title="Toggle Line Wrap">
Crayon-button-icon">
Crayon-button Crayon-expand-button" title="Expand Code">
Crayon-button-icon">
Crayon-button Crayon-copy-button" title="Copy">
Crayon-button-icon">
Crayon-button Crayon-popup-button" title="Open Code In New Window">
Crayon-button-icon">
Crayon-language">PHP
Crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
Crayon-plain-wrap">
Crayon-main" style="">Crayon-table">Crayon-row">
Crayon-nums " data-settings="show">
Crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
Crayon-num" data-line="Crayon-5c891d17cea1a779063338-1">1
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d17cea1a779063338-2">2
Crayon-num" data-line="Crayon-5c891d17cea1a779063338-3">3
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d17cea1a779063338-4">4
Crayon-num" data-line="Crayon-5c891d17cea1a779063338-5">5
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d17cea1a779063338-6">6
Crayon-num" data-line="Crayon-5c891d17cea1a779063338-7">7
Crayon-num Crayon-striped-num" data-line="Crayon-5c891d17cea1a779063338-8">8
Crayon-num" data-line="Crayon-5c891d17cea1a779063338-9">9
Crayon-code">
Crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
Crayon-line" id="Crayon-5c891d17cea1a779063338-1">Crayon-ta">PHPCrayon-h">
Crayon-line Crayon-striped-line" id="Crayon-5c891d17cea1a779063338-2">Crayon-h"> Crayon-c">/* Plugin Name: Block Bad Queries */
Crayon-line" id="Crayon-5c891d17cea1a779063338-3">Crayon-h"> Crayon-st">ifCrayon-h"> Crayon-sy">(Crayon-e">strlenCrayon-sy">(Crayon-v">$_SERVERCrayon-sy">[Crayon-s">'REQUEST_URI'Crayon-sy">]Crayon-sy">)Crayon-h"> Crayon-h"> Crayon-cn">255Crayon-h"> Crayon-o">||Crayon-h"> Crayon-e">strposCrayon-sy">(Crayon-v">$_SERVERCrayon-sy">[Crayon-s">'REQUEST_URI'Crayon-sy">]Crayon-sy">,Crayon-h"> Crayon-s">"eval("Crayon-sy">)Crayon-h"> Crayon-o">||Crayon-e">strposCrayon-sy">(Crayon-v">$_SERVERCrayon-sy">[Crayon-s">'REQUEST_URI'Crayon-sy">]Crayon-sy">,Crayon-h"> Crayon-s">"base64"Crayon-sy">)Crayon-sy">)Crayon-h"> Crayon-sy">{
Crayon-line Crayon-striped-line" id="Crayon-5c891d17cea1a779063338-4">Crayon-h"> Crayon-sy">@Crayon-e">headerCrayon-sy">(Crayon-s">"HTTP/1.1 414 Request-URI Too Long"Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891d17cea1a779063338-5">Crayon-h"> Crayon-sy">@Crayon-e">headerCrayon-sy">(Crayon-s">"Status: 414 Request-URI Too Long"Crayon-sy">)Crayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d17cea1a779063338-6">Crayon-h"> Crayon-sy">@Crayon-e">headerCrayon-sy">(Crayon-s">"Connection: Close"Crayon-sy">)Crayon-sy">;
Crayon-line" id="Crayon-5c891d17cea1a779063338-7">Crayon-h"> Crayon-sy">@Crayon-k ">exitCrayon-sy">;
Crayon-line Crayon-striped-line" id="Crayon-5c891d17cea1a779063338-8">Crayon-h"> Crayon-sy">}Crayon-h">
Crayon-line" id="Crayon-5c891d17cea1a779063338-9">

猜你在找的wordpress相关文章