{"id":4339,"date":"2021-01-18T15:10:49","date_gmt":"2021-01-18T07:10:49","guid":{"rendered":"https:\/\/www.baishitou.cn\/?p=4339"},"modified":"2021-01-18T15:14:42","modified_gmt":"2021-01-18T07:14:42","slug":"wordpress%e7%a6%81%e6%ad%a2%e6%90%9c%e7%b4%a2%e5%bc%95%e6%93%8e%e6%8a%93%e5%8f%96%e6%8c%87%e5%ae%9a%e8%b7%af%e5%be%84%e6%88%96%e8%80%85%e6%98%af%e5%8a%a8%e6%80%81%e8%b7%af%e5%be%84%e9%a1%b5%e9%9d%a2","status":"publish","type":"post","link":"https:\/\/www.baishitou.cn\/4339.html","title":{"rendered":"wordpress\u7981\u6b62\u641c\u7d22\u5f15\u64ce\u6293\u53d6\u6307\u5b9a\u8def\u5f84\u6216\u8005\u662f\u52a8\u6001\u8def\u5f84\u9875\u9762"},"content":{"rendered":"

\u4eca\u5929\u67e5\u8be2\u53d1\u73b0\u4e0a\u5348\u53d1\u5e03\u7684\u4e00\u7bc7\u6587\u7ae0\u88ab\u6536\u5f55\u4e86\uff0c\u4f46\u6536\u5f55\u7684\u5730\u5740\u5374\u662f\u52a8\u6001\u7684\u3002<\/p>\n

\"\"<\/a><\/p>\n

\u53ef\u4ee5\u6211\u7684\u7f51\u7ad9\u662f\u4f2a\u9759\u6001\u7684\uff0c\u6240\u4ee5\u5c31\u4e0d\u60f3\u8ba9\u5b83\u6536\u5f55\u52a8\u6001\u9875\u9762\u3002robots\u91cc\u9762\u52a0\u5165\u4e86\u7981\u6b62\u6293\u53d6\u8fd9\u4e9b\u52a8\u6001\u5730\u5740\u548c\u67d0\u4e9b\u8def\u5f84\uff0c\u4f46\u662f\u8718\u86db\u4f9d\u7136\u6bcf\u5929\u6293\u53d6\uff0c\u800c\u4e14\u8fd8\u6536\u5f55\u4e86\uff01\u6240\u4ee5\u53ea\u80fd\u5f3a\u5236\u7981\u6b62\u5b83\u8bbf\u95ee\u3002<\/p>\n

\u628a\u4e0b\u5217\u4ee3\u7801\u52a0\u5165\u5230\u670d\u52a1\u5668\u914d\u7f6e\u6587\u4ef6ROOT\u540e\u9762\u5373\u53ef<\/p>\n

#### \u7981\u6b62\u641c\u7d22\u5f15\u64ce\u8bbf\u95ee\u6307\u5b9a\u6587\u4ef6\u5939\u6216\u8005\u8def\u5f84 \u3010\u5f00\u59cb\u3011####\r\n    #\u521d\u59cb\u5316\u53d8\u91cf\u4e3a\u7a7a\r\n    set $deny_spider \"\";\r\n    #\u5982\u679c\u8bf7\u6c42\u5730\u5740\u4e2d\u542b\u6709\u9700\u8981\u7981\u6b62\u6293\u53d6\u5173\u952e\u8bcd\u65f6\uff0c\u5c06\u53d8\u91cf\u8bbe\u7f6e\u4e3ay\uff1a\r\n    if ($request_uri  ~* \"\\?replytocom=(\\d+)|\\?p=(\\d+)|\/feed|\/date|\/wp-admin|comment-page-(\\d+)|\/go\") {\r\n         set $deny_spider 'y';\r\n    }\r\n    #\u5982\u679c\u6293\u53d6\u7684UA\u4e2d\u542b\u6709spider\u6216bot\u65f6\uff0c\u7ee7\u7eed\u4e3a\u53d8\u91cf\u8d4b\u503c\uff08\u901a\u8fc7\u7d2f\u52a0\u8d4b\u503c\u95f4\u63a5\u5b9e\u73b0nginx\u7684\u591a\u91cd\u6761\u4ef6\u5224\u65ad\uff09\r\n    if ($http_user_agent ~* \"spider|bot\") {\r\n     set $deny_spider \"${deny_spider}es\";\r\n    }\r\n    #\u5f53\u6ee1\u8db3\u4ee5\u4e0a2\u4e2a\u6761\u4ef6\u65f6\uff0c\u5219\u8fd4\u56de404\uff0c\u7b26\u5408\u641c\u7d22\u5f15\u64ce\u6b7b\u94fe\u6807\u51c6\r\n     if ($deny_spider = 'yes') {\r\n         return 403; #\u5982\u679c\u662f\u5220\u9664\u5df2\u6536\u5f55\u7684\uff0c\u5219\u53ef\u4ee5\u8fd4\u56de404\r\n         break;\r\n     }\r\n     #### \u7981\u6b62\u641c\u7d22\u5f15\u64ce\u8bbf\u95ee\u6307\u5b9a\u6587\u4ef6\u5939\u6216\u8005\u8def\u5f84\u3010\u7ed3\u675f\u3011 ####<\/code><\/pre>\n

\"\"<\/a><\/p>\n

\u7136\u540e\u6d4b\u8bd5\u4e00\u4e0b\uff0c\u52a8\u6001\u5730\u5740\u6293\u53d6\u5931\u8d25\uff0c\u9759\u6001\u5730\u5740\u6210\u529f\u3002<\/p>\n

\"\"<\/a><\/p>\n

\u8fd8\u6709\u4e00\u79cd\u65b9\u6cd5\u5c31\u662f\u628a\u4ee3\u7801\u76f4\u63a5\u5199\u8fdb\u5f53\u524d\u4e3b\u9898\u9875\u7684functions.php\u91cc\u9762\u5373\u53ef\u3002<\/p>\n

PHP\u4ee3\u7801\u5982\u4e0b<\/p>\n

\/*\u7981\u6b62\u8718\u86db\u6293\u53d6\u6307\u5b9a\u8def\u5f84\u4ee3\u7801*\/\r\nob_start(\"Deny_Spider_Advanced\");\r\nfunction Deny_Spider_Advanced() {\r\n    $UA = $_SERVER['HTTP_USER_AGENT'];\r\n    $Request_uri = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];\r\n    $Spider_UA  = '\/(spider|bot|)\/i'; \/\/\u5b9a\u4e49\u9700\u8981\u7981\u6b62\u7684\u8718\u86dbUA\uff0c\u4e00\u822c\u662fspider\u548cbot\r\n    \/\/\u7981\u6b62\u8718\u86db\u6293\u53d6\u7684\u8def\u5f84\uff0c\u53ef\u4ee5\u53c2\u8003\u81ea\u5df1\u7684robots\u5185\u5bb9\uff0c\u6bcf\u4e2a\u5173\u952e\u8bcd\u7528\u5206\u9694\u7b26\u9694\u5f00\uff0c\u9700\u6ce8\u610f\u7279\u6b8a\u5b57\u7b26\u7684\u8f6c\u4e49\r\n    $Deny_path  = '\/\\?replytocom=(\\d+)|\\?p=(\\d+)|\\\/feed|\\\/date|\\\/wp-admin|wp-includes|\\\/go|comment-page-(\\d+)\/i';\r\n    \/\/\u5982\u679c\u68c0\u6d4b\u5230UA\u4e3a\u7a7a\uff0c\u53ef\u80fd\u662f\u91c7\u96c6\u884c\u4e3a\r\n    if(!$UA) {\r\n        header(\"Content-type: text\/html; charset=utf-8\");\r\n        wp_die('\u8bf7\u52ff\u91c7\u96c6\u672c\u7ad9\uff0c\u56e0\u4e3a\u91c7\u96c6\u7684\u7ad9\u957f\u6728\u6709\u5c0fJJ\uff01');\r\n    } else {\r\n        \/\/\u5982\u679c\u53d1\u73b0\u662f\u8718\u86db\uff0c\u5e76\u4e14\u6293\u53d6\u8def\u5f84\u5339\u914d\u5230\u4e86\u7981\u6b62\u6293\u53d6\u5173\u952e\u8bcd\u5219\u8fd4\u56de404\u6216\u8005403\r\n        if(preg_match_all($Spider_UA,$UA) && preg_match_all($Deny_path,$Request_uri)) {\r\n             \/\/header('HTTP\/1.1 404 Not Found');  \r\n             \/\/header(\"status: 404 Not Found\");       \r\n             header('HTTP\/1.1 403 Forbidden'); \r\n             header(\"status: 403 Forbidden\");             \r\n        }\r\n    }\r\n}<\/code><\/pre>\n

\u5199\u5728\u6700\u540e\uff0c\u6211\u5728\u53d1\u5e03\u8fd9\u4e2a\u7bc7\u6587\u7ae0\u65f6\uff0c\u53d1\u73b0\u53d1\u5e03\u6309\u94ae\u662f\u7070\u8272\u4e0d\u53ef\u7528\u7684\u3002\u7528\u63a7\u5236\u53f0\u68c0\u67e5\u53d1\u73b0\u6709\u9519\u8bef\uff1aFailed to load resource: the server responded with a status of 403 ()<\/p>\n

\u539f\u6765\u662f\u4e0a\u9762\u89c4\u5219\u4e2d\u8bbf\u95ee\u540e\u53f0\u76ee\u5f55\u4f1a\u51fa\u73b0403\u9519\u8bef\u3002\u628a\u540e\u53f0\u76ee\u5f55\u4ece\u4e0a\u9762\u89c4\u5219\u91cc\u5220\u9664\u5373\u53ef\u3002<\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

\u4eca\u5929\u67e5\u8be2\u53d1\u73b0\u4e0a\u5348\u53d1\u5e03\u7684\u4e00\u7bc7\u6587\u7ae0\u88ab\u6536\u5f55\u4e86\uff0c\u4f46\u6536\u5f55\u7684\u5730\u5740\u5374\u662f\u52a8\u6001\u7684\u3002 \u53ef\u4ee5\u6211\u7684\u7f51\u7ad9\u662f\u4f2a\u9759\u6001\u7684\uff0c\u6240\u4ee5\u5c31\u4e0d\u60f3\u8ba9\u5b83\u6536\u5f55\u52a8 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[5,1388,1387,1386,852],"class_list":["post-4339","post","type-post","status-publish","format-standard","hentry","category-wljs","tag-wordpress","tag-1388","tag-1387","tag-1386","tag-852"],"_links":{"self":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/4339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/comments?post=4339"}],"version-history":[{"count":0,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/posts\/4339\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/media?parent=4339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/categories?post=4339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.baishitou.cn\/wp-json\/wp\/v2\/tags?post=4339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}