WordPress( .htaccess )如何禁止SQL查询或禁止垃圾信息请求
WordPress如何禁止SQL查询或禁止垃圾信息请求,也是为了提高网站的安全性,若我们使用Apache引擎或LAMP环境,我们只需要在根目录的 .htaccess 文件中添加以下代码即可。
1、禁止机器人请求
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REQUEST_URI} .wp-comments-post\.php*
RewriteCond %{HTTP_REFERER} !.wordpress.dev.* [OR]
RewriteCond %{HTTP_USER_AGENT} ^$
RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L]
</IfModule>
2、禁止SQL查询
<IfModule mod_rewrite.c>
RewriteBase /
RewriteCond %{REQUEST_METHOD} ^(HEAD|TRACE|DELETE|TRACK) [NC]
RewriteRule ^(.*)$ - [F,L]
RewriteCond %{QUERY_STRING} \.\.\/ [NC,OR]
RewriteCond %{QUERY_STRING} boot\.ini [NC,OR]
RewriteCond %{QUERY_STRING} tag\= [NC,OR]
RewriteCond %{QUERY_STRING} ftp\: [NC,OR]
RewriteCond %{QUERY_STRING} http\: [NC,OR]
RewriteCond %{QUERY_STRING} https\: [NC,OR]
RewriteCond %{QUERY_STRING} (\|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [NC,OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(\[|\]|\(|\)||ê|"|;|\?|\*|=$).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*("|'|<|>|\|{||).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%24&x).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(%0|%A|%B|%C|%D|%E|%F|127\.0).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(globals|encode|localhost|loopback).* [NC,OR]
RewriteCond %{QUERY_STRING} ^.*(request|select|insert|union|declare).* [NC]
RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in_.*$
RewriteRule ^(.*)$ - [F,L]
</IfModule>
3、禁止垃圾信息请求
<ifModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} enter|separated|query|strings|here [NC]
RewriteRule .* http://www.%{HTTP_HOST}/$1? [R=301,L]
</ifModule>
当然,提高网站的安全性不止这些,更多还需靠自己在运营过程中发现。
-
WordPress媒体库图片默认全尺寸规格之解决图片不清晰问题追格小程序用户经常咨询的一个问题,为什么我的图片这么模糊,很多时候都是因为选了微缩图或中等尺寸图片,当你选择这些规格后,WordPress即默认该规格,除非发文的时候选择其他规格。
-
WordPress如何移除RSD和wlwmanifestWordPress如何移除RSD 和 wlwmanifest,在当前WordPress主题的 functions.php 文件中插入下面这段代码即可。
-
WordPress如何移除wpembed TinyMCE 插件WordPress如何移除 wpembed TinyMCE 插件,我们只需在当前WordPress主题的 functions.php 文件中插入下面这段代码即可。
-
WordPress如何移除Meta中的Post信息WordPress如何移除 Meta 中的 Post 信息,我们只需在当前WordPress主题的 functions.php 文件中插入下面这段代码即可。
-
WordPress如何在指定文章中不显示短代码WordPress若想在指定文章中不显示短代码,可以按追格小编的方法操作。
-
WordPress插件:Fixed Widget小工具跟随滚动选项插件Fixed Widget是一款让指定的小工具跟随页面滚动,始终保持在屏幕可见区域中的WordPress插件。
暂无评论,抢个沙发...