{"id":199,"date":"2010-12-07T09:19:19","date_gmt":"2010-12-07T01:19:19","guid":{"rendered":"http:\/\/www.cnmiss.cn\/?p=199"},"modified":"2010-12-07T09:19:19","modified_gmt":"2010-12-07T01:19:19","slug":"%e6%9c%80%e5%ae%8c%e6%95%b4%e7%9a%84htaccess%e6%96%87%e4%bb%b6%e7%94%a8%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.cnmiss.cn\/?p=199","title":{"rendered":"\u6700\u5b8c\u6574\u7684htaccess\u6587\u4ef6\u7528\u6cd5"},"content":{"rendered":"<p><strong>1.\u65f6\u533a\u8bbe\u7f6e<br \/>\n<\/strong>\u6709\u4e9b\u65f6\u5019\uff0c\u5f53\u4f60\u5728PHP\u91cc\u4f7f\u7528date\u6216mktime\u51fd\u6570\u65f6\uff0c\u7531\u4e8e\u65f6\u533a\u7684\u4e0d\u540c\uff0c\u5b83\u4f1a\u663e\u793a\u51fa\u4e00\u4e9b\u5f88\u5947\u602a\u7684\u4fe1\u606f\u3002\u4e0b\u9762\u662f\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002\u5c31\u662f\u8bbe\u7f6e\u4f60\u7684\u670d\u52a1\u5668\u7684\u65f6\u533a\u3002\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\u6240\u6709\u652f\u6301\u7684\u65f6\u533a\u7684\u6e05\u5355\u3002<\/p>\n<blockquote><p>\u00a0SetEnv TZ Australia\/Melbourne<\/p><\/blockquote>\n<p><strong>2. \u641c\u7d22\u5f15\u64ce\u53cb\u597d\u7684301\u6c38\u4e45\u8f6c\u5411\u65b9\u6cd5<br \/>\n<\/strong>\u4e3a\u4ec0\u4e48\u8fd9\u662f\u641c\u7d22\u5f15\u64ce\u53cb\u597d\u7684\u5462\uff1f\u56e0\u4e3a\u73b0\u5728\u5f88\u591a\u73b0\u4ee3\u7684\u641c\u7d22\u5f15\u64ce\u90fd\u6709\u80fd\u6839\u636e\u68c0\u67e5301\u6c38\u4e45\u8f6c\u5411\u6765\u66f4\u65b0\u5b83\u73b0\u6709\u7684\u8bb0\u5f55\u7684\u529f\u80fd\u3002<\/p>\n<blockquote><p>Redirect 301 <a href=\"https:\/\/www.cnmiss.cn\/home\">https:\/\/www.cnmiss.cn\/home<\/a> <a href=\"https:\/\/www.cnmiss.cn\/\">https:\/\/www.cnmiss.cn\/<\/a><\/p><\/blockquote>\n<p><strong>3. \u5c4f\u853d\u4e0b\u8f7d\u5bf9\u8bdd\u6846<br \/>\n<\/strong>\u901a\u5e38\uff0c\u5f53\u4f60\u4e0b\u8f7d\u4e1c\u897f\u7684\u65f6\u5019\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u4e2a\u5bf9\u8bdd\u6846\u8be2\u95ee\u4f60\u662f\u4fdd\u6301\u8fd9\u4e2a\u6587\u4ef6\u8fd8\u662f\u76f4\u63a5\u6253\u5f00\u5b83\u3002\u5982\u679c\u4f60\u4e0d\u60f3\u770b\u5230\u8fd9\u4e2a\u4e1c\u897f\uff0c\u4f60\u53ef\u4ee5\u628a\u4e0b\u9762\u7684\u4e00\u6bb5\u4ee3\u7801\u653e\u5230\u4f60\u7684.htaccess\u6587\u4ef6\u91cc\u3002<\/p>\n<blockquote><p>AddType application\/octet-stream .pdf\u00a0<br \/>\nAddType application\/octet-stream .zip\u00a0<br \/>\nAddType application\/octet-stream .mov<\/p><\/blockquote>\n<p><strong>4. \u7701\u53bbwww\u524d\u7f00<br \/>\n<\/strong>SEO\u7684\u4e00\u4e2a\u539f\u5219\u662f\uff0c\u786e\u4fdd\u4f60\u7684\u7f51\u7ad9\u53ea\u6709\u4e00\u4e2aURL\u3002\u56e0\u6b64\uff0c\u4f60\u9700\u8981\u628a\u6240\u6709\u7684\u901a\u8fc7www\u7684\u8bbf\u95ee\u8f6c\u5411\u7684\u975ewww\uff0c\u6216\u8005\u53cd\u8fd9\u6765\u3002<\/p>\n<blockquote><p>RewriteEngine On\u00a0<br \/>\nRewriteBase \/\u00a0<br \/>\nRewriteCond %{HTTP_HOST} ^www.lvtao.net [NC]\u00a0<br \/>\nRewriteRule ^(.*)$ <a href=\"http:\/\/cnmiss.cn\/$1\">http:\/\/cnmiss.cn\/$1<\/a> [L,R=301]\u00a0<\/p><\/blockquote>\n<p><strong>5. \u4e2a\u6027\u5316Error\u9875\u9762<br \/>\n<\/strong>\u5bf9\u6bcf\u4e2a\u9519\u8bef\u4ee3\u7801\u5b9a\u5236\u81ea\u5df1\u4e2a\u6027\u5316\u7684\u9519\u8bef\u9875\u9762\u3002<\/p>\n<blockquote><p>ErrorDocument 401 \/error\/401.php\u00a0<br \/>\nErrorDocument 403 \/error\/403.php\u00a0<br \/>\nErrorDocument 404 \/error\/404.php\u00a0<br \/>\nErrorDocument 500 \/error\/500.php<\/p><\/blockquote>\n<p><strong>6. \u538b\u7f29\u6587\u4ef6<br \/>\n<\/strong>\u901a\u8fc7\u538b\u7f29\u4f60\u7684\u6587\u4ef6\u4f53\u79ef\u6765\u4f18\u5316\u7f51\u7ad9\u7684\u8bbf\u95ee\u901f\u5ea6\u3002<\/p>\n<blockquote><p># \u538b\u7f29 text, html, javascript, css, xml:\u00a0<br \/>\nAddOutputFilterByType DEFLATE text\/plain\u00a0<br \/>\nAddOutputFilterByType DEFLATE text\/html\u00a0<br \/>\nAddOutputFilterByType DEFLATE text\/xml\u00a0<br \/>\nAddOutputFilterByType DEFLATE text\/css\u00a0<br \/>\nAddOutputFilterByType DEFLATE application\/xml\u00a0<br \/>\nAddOutputFilterByType DEFLATE application\/xhtml+xml\u00a0<br \/>\n8.AddOutputFilterByType DEFLATE application\/rss+xml\u00a0<br \/>\n9.AddOutputFilterByType DEFLATE application\/javascript\u00a0<br \/>\n10.AddOutputFilterByType DEFLATE application\/x-javascript<\/p><\/blockquote>\n<p><strong>7. \u7f13\u5b58\u6587\u4ef6<br \/>\n<\/strong>\u7f13\u5b58\u6587\u4ef6\u662f\u53e6\u5916\u4e00\u4e2a\u63d0\u9ad8\u4f60\u7684\u7f51\u7ad9\u8bbf\u95ee\u901f\u5ea6\u7684\u597d\u65b9\u6cd5\u3002<\/p>\n<blockquote><p>&lt;FilesMatch &#8220;.(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$&#8221;&gt;\u00a0<br \/>\nHeader set Cache-Control &#8220;max-age=2592000&#8221;<br \/>\n&lt;\/FilesMatch&gt;\u00a0&gt;<\/p><\/blockquote>\n<p><strong>8. \u5bf9\u67d0\u4e9b\u6587\u4ef6\u7c7b\u578b\u7981\u6b62\u4f7f\u7528\u7f13\u5b58<br \/>\n<\/strong>\u800c\u53e6\u4e00\u65b9\u9762\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5b9a\u5236\u5bf9\u67d0\u4e9b\u6587\u4ef6\u7c7b\u578b\u7981\u6b62\u4f7f\u7528\u7f13\u5b58\u3002<\/p>\n<blockquote><p># \u663e\u5f0f\u7684\u89c4\u5b9a\u5bf9\u811a\u672c\u548c\u5176\u5b83\u52a8\u6001\u6587\u4ef6\u7981\u6b62\u4f7f\u7528\u7f13\u5b58\u00a0<br \/>\n&lt;FilesMatch &#8220;.(pl|php|cgi|spl|scgi|fcgi)$&#8221;&gt;\u00a0<br \/>\nHeader unset Cache-Control\u00a0<br \/>\n&lt;\/FilesMatch&gt;\u00a0<\/p><\/blockquote>\n<p><strong>\u5b89\u5168\u95ee\u9898<\/strong><\/p>\n<p>\u4e0b\u9762\u7684htaccess\u4ee3\u7801\u80fd\u591f\u63d0\u9ad8\u4f60\u7684web\u670d\u52a1\u5668\u7684\u5b89\u5168\u6c34\u5e73\u3002\u56fe\u7247\u94fe\u63a5\u76d7\u7528\u4fdd\u62a4\u975e\u5e38\u6709\u7528\uff0c\u5b83\u80fd\u9632\u6b62\u5176\u4ed6\u4eba\u5077\u76d7\u4f7f\u7528\u4f60\u7684\u670d\u52a1\u5668\u4e0a\u7684\u56fe\u7247\u8d44\u6e90\u3002<\/p>\n<p><strong>1. \u901a\u8fc7.htaccess\u653e\u76d7\u94fe<br \/>\n<\/strong>\u75db\u6068\u90a3\u4e9b\u5077\u76d7\u94fe\u63a5\u4f60\u7684web\u670d\u52a1\u5668\u4e0a\u7684\u56fe\u7247\u8d44\u6e90\u800c\u8017\u5c3d\u4e86\u4f60\u7684\u5e26\u5bbd\u7684\u884c\u4e3a\u5417\uff1f\u8bd5\u8bd5\u8fd9\u4e2a\uff0c\u4f60\u53ef\u4ee5\u9632\u6b62\u8fd9\u79cd\u4e8b\u60c5\u7684\u53d1\u751f\u3002<\/p>\n<blockquote><p>RewriteBase \/\u00a0<br \/>\nRewriteCond %{HTTP_REFERER} !^$\u00a0<br \/>\nRewriteCond %{HTTP_REFERER} !^http:\/\/(<a href=\"http:\/\/www.)\/?cnmiss.cn\/.*$\">www.)?cnmiss.cn\/.*$<\/a> [NC]\u00a0<br \/>\nRewriteRule .(gif|jpg|swf|flv|png)$ \/feed\/ [R=302,L]\u00a0<\/p><\/blockquote>\n<p><strong>2. \u9632\u9ed1\u5ba2<br \/>\n<\/strong>\u5982\u679c\u4f60\u60f3\u63d0\u9ad8\u7f51\u7ad9\u7684\u5b89\u5168\u7b49\u7ea7\uff0c\u4f60\u53ef\u4ee5\u52a0\u4e0a\u4e0b\u9762\u7684\u51e0\u884c\u4ee3\u7801\uff0c\u8fd9\u6837\u53ef\u4ee5\u9632\u6b62\u4e00\u4e9b\u5e38\u89c1\u6076\u610fURL\u5339\u914d\u7684\u9ed1\u5ba2\u653b\u51fb\u6280\u672f\u3002<\/p>\n<blockquote><p>RewriteEngine On\u00a0<br \/>\n\u00a0<br \/>\n# proc\/self\/environ? \u6ca1\u95e8\uff01\u00a0<br \/>\nRewriteCond %{QUERY_STRING} proc\/self\/environ [OR]\u00a0<br \/>\n\u00a0<br \/>\n# \u963b\u6b62\u811a\u672c\u4f01\u56fe\u901a\u8fc7URL\u4fee\u6539mosConfig\u503c\u00a0<br \/>\nRewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\\%3D) [OR]\u00a0<br \/>\n\u00a0<br \/>\n# \u963b\u6b62\u811a\u672c\u901a\u8fc7URL\u4f20\u9012\u7684base64_encode\u5783\u573e\u4fe1\u606f\u00a0<br \/>\nRewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR]\u00a0<br \/>\n\u00a0<br \/>\n# \u963b\u6b62\u5728URL\u542b\u6709&lt;script&gt;\u6807\u8bb0\u7684\u811a\u672c\u00a0<br \/>\nRewriteCond %{QUERY_STRING} (&lt;|%3C).*script.*(&gt;|%3E) [NC,OR]\u00a0<br \/>\n\u00a0<br \/>\n# \u963b\u6b62\u4f01\u56fe\u901a\u8fc7URL\u8bbe\u7f6ePHP\u7684GLOBALS\u53d8\u91cf\u7684\u811a\u672c\u00a0<br \/>\nRewriteCond %{QUERY_STRING} GLOBALS(=|[|\\%[0-9A-Z]{0,2}) [OR]\u00a0<br \/>\n\u00a0<br \/>\n# \u963b\u6b62\u4f01\u56fe\u901a\u8fc7URL\u8bbe\u7f6ePHP\u7684_REQUEST\u53d8\u91cf\u7684\u811a\u672c\u00a0<br \/>\nRewriteCond %{QUERY_STRING} _REQUEST(=|[|\\%[0-9A-Z]{0,2})\u00a0<br \/>\n\u00a0<br \/>\n# \u628a\u6240\u6709\u88ab\u963b\u6b62\u7684\u8bf7\u6c42\u8f6c\u5411\u5230403\u7981\u6b62\u63d0\u793a\u9875\u9762\uff01\u00a0<br \/>\nRewriteRule ^(.*)$ index.php [F,L]\u00a0<\/p><\/blockquote>\n<p><strong>3. \u963b\u6b62\u8bbf\u95ee\u4f60\u7684 .htaccess \u6587\u4ef6<br \/>\n<\/strong>\u4e0b\u9762\u7684\u4ee3\u7801\u53ef\u4ee5\u963b\u6b62\u522b\u4eba\u8bbf\u95ee\u4f60\u7684.htaccess\u6587\u4ef6\u3002\u540c\u6837\uff0c\u4f60\u4e5f\u53ef\u4ee5\u8bbe\u5b9a\u963b\u6b62\u591a\u79cd\u6587\u4ef6\u7c7b\u578b\u3002<\/p>\n<blockquote><p># \u4fdd\u62a4\u4f60\u7684 htaccess \u6587\u4ef6\u00a0<br \/>\n&lt;Files .htaccess&gt;\u00a0<br \/>\norder allow,deny\u00a0<br \/>\ndeny from all\u00a0<br \/>\n&lt;\/Files&gt;\u00a0<br \/>\n\u00a0<br \/>\n# \u963b\u6b62\u67e5\u770b\u6307\u5b9a\u7684\u6587\u4ef6\u00a0<br \/>\n&lt;Files secretfile.jpg&gt;\u00a0<br \/>\norder allow,deny\u00a0<br \/>\ndeny from all\u00a0<br \/>\n&lt;\/Files&gt;\u00a0<br \/>\n\u00a0<br \/>\n# \u591a\u79cd\u6587\u4ef6\u7c7b\u578b\u00a0<br \/>\n&lt;FilesMatch \u201c.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$\u201d&gt;\u00a0<br \/>\nOrder Allow,Deny\u00a0<br \/>\nDeny from all\u00a0<br \/>\n&lt;\/FilesMatch&gt;<\/p><\/blockquote>\n<p><strong>4. \u91cd\u547d\u540d htaccess \u6587\u4ef6<br \/>\n<\/strong>\u4f60\u53ef\u4ee5\u901a\u8fc7\u91cd\u547d\u540dhtaccess\u6587\u4ef6\u6765\u5bf9\u5176\u8fdb\u884c\u4fdd\u62a4\u3002<\/p>\n<blockquote><p>AccessFileName htacc.ess<\/p><\/blockquote>\n<p><strong>5. \u7981\u6b62\u76ee\u5f55\u6d4f\u89c8<br \/>\n<\/strong>\u7981\u6b62\u670d\u52a1\u5668\u5bf9\u5916\u663e\u793a\u76ee\u5f55\u7ed3\u6784\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002<\/p>\n<blockquote><p># \u7981\u6b62\u76ee\u5f55\u6d4f\u89c8\u00a0<br \/>\nOptions All -Indexes\u00a0<br \/>\n\u00a0<br \/>\n# \u5f00\u653e\u76ee\u5f55\u6d4f\u89c8<br \/>\nOptions All +Indexes<\/p><\/blockquote>\n<p><strong>6. \u6539\u53d8\u7f3a\u7701\u7684Index\u9875\u9762<br \/>\n<\/strong>\u4f60\u53ef\u4ee5\u628a\u7f3a\u7701\u7684 index.html, index.php \u6216 index.htm \u6539\u6210\u5176\u5b83\u9875\u9762\u3002<\/p>\n<blockquote><p>DirectoryIndex business.html<\/p><\/blockquote>\n<p><strong>7. \u901a\u8fc7\u5f15\u7528\u4fe1\u606f\u6765\u963b\u6b62\u67d0\u4e9b\u4e0d\u6b22\u8fce\u7684\u6d4f\u89c8\u8005<\/strong><\/p>\n<blockquote><p># \u963b\u6b62\u6765\u81ea\u67d0\u7f51\u7ad9\u7684\u7528\u6237\u00a0<br \/>\n&lt;IfModule mod_rewrite.c&gt;\u00a0<br \/>\nRewriteEngine on\u00a0<br \/>\nRewriteCond %{HTTP_REFERER} scumbag.com [NC,OR]\u00a0<br \/>\nRewriteCond %{HTTP_REFERER} wormhole.com [NC,OR]\u00a0<br \/>\nRewriteRule .* &#8211; [F]\u00a0<br \/>\n\u00a0\u00a0<br \/>\n&lt;\/ifModule&gt;<\/p><\/blockquote>\n<p><strong>8. \u901a\u8fc7\u5224\u65ad\u6d4f\u89c8\u5668\u5934\u4fe1\u606f\u6765\u963b\u6b62\u67d0\u4e9b\u8bf7\u6c42<br \/>\n<\/strong>\u8fd9\u4e2a\u65b9\u6cd5\u53ef\u4ee5\u901a\u8fc7\u963b\u6b62\u67d0\u4e9b\u673a\u5668\u4eba\u6216\u8718\u86db\u722c\u866b\u6293\u53d6\u4f60\u7684\u7f51\u7ad9\u6765\u8282\u7701\u4f60\u7684\u5e26\u5bbd\u6d41\u91cf\u3002<\/p>\n<blockquote><p># \u963b\u6b62\u6765\u81ea\u67d0\u4e9b\u7279\u5b9a\u7f51\u7ad9\u7684\u7528\u6237\u00a0<br \/>\n&lt;IfModule mod_rewrite.c&gt;\u00a0<br \/>\nSetEnvIfNoCase ^User-Agent$ .*(craftbot|download|extract|stripper|sucker|ninja|clshttp|webspider|leacher|collector|grabber|webpictures) HTTP_SAFE_BADBOT\u00a0SetEnvIfNoCase ^User-Agent$ .*(libwww-perl|aesop_com_spiderman) HTTP_SAFE_BADBOT\u00a0Deny from env=HTTP_SAFE_BADBOT\u00a0<br \/>\n&lt;\/ifModule&gt;<\/p><\/blockquote>\n<p><strong>9. \u7981\u6b62\u811a\u672c\u6267\u884c\uff0c\u52a0\u5f3a\u4f60\u7684\u76ee\u5f55\u5b89\u5168<\/strong><\/p>\n<blockquote><p># \u7981\u6b62\u67d0\u4e9b\u76ee\u5f55\u91cc\u7684\u811a\u672c\u6267\u884c\u6743\u9650\u00a0<br \/>\nAddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi\u00a0<br \/>\nOptions -ExecCGI<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>1.\u65f6\u533a\u8bbe\u7f6e \u6709\u4e9b\u65f6\u5019\uff0c\u5f53\u4f60\u5728PHP\u91cc\u4f7f\u7528date\u6216mktime\u51fd\u6570\u65f6\uff0c\u7531\u4e8e\u65f6\u533a &hellip; <a href=\"https:\/\/www.cnmiss.cn\/?p=199\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[9,25,27,33],"class_list":["post-199","post","type-post","status-publish","format-standard","hentry","category-xxbj","tag-9","tag-php","tag-seo","tag-33"],"_links":{"self":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199"}],"version-history":[{"count":0,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cnmiss.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}