{"id":1864,"date":"2024-06-05T20:19:42","date_gmt":"2024-06-05T12:19:42","guid":{"rendered":"https:\/\/cn.raksmart.com\/blog\/host\/3853.html"},"modified":"2024-06-05T20:19:42","modified_gmt":"2024-06-05T12:19:42","slug":"%e9%80%9a%e8%bf%87htaccess%e6%96%87%e4%bb%b6%e7%bc%96%e8%be%91%e6%9d%a5%e9%98%b2%e6%ad%a2%e5%9b%be%e7%89%87%e7%9b%97%e9%93%be","status":"publish","type":"post","link":"https:\/\/cn.raksmart.com\/blog\/knowledge\/1864.html","title":{"rendered":"\u901a\u8fc7htaccess\u6587\u4ef6\u7f16\u8f91\u6765\u9632\u6b62\u56fe\u7247\u76d7\u94fe"},"content":{"rendered":"<div class=\"entry-content e-content\" itemprop=\"description articleBody\">\n<p>\u70ed\u94fe\u63a5\u6216\u5e26\u5bbd\u7a83\u53d6\u662f\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\u3002\u5f53\u4eba\u4eec\u94fe\u63a5\u5230\u4e0d\u540c<a href=\"https:\/\/cn.raksmart.com\/dedicate\" target=\"_blank\" rel=\"noopener\">\u72ec\u7acb\u670d\u52a1\u5668<\/a>\u4e0a\u7684\u6587\u4ef6\u548c\u56fe\u50cf\u5e76\u5c06\u5b83\u4eec\u663e\u793a\u5728\u4ed6\u4eec\u81ea\u5df1\u7684\u7f51\u7ad9\u4e0a\u65f6\uff0c\u5c31\u4f1a\u53d1\u751f\u8fd9\u79cd\u60c5\u51b5;\u8fd9\u4f7f\u7528\u4e86\u539f\u59cb\u6240\u6709\u8005\u7684\u5e26\u5bbd\uff0c\u8d39\u7528\u7531\u4ed6\u4eec\u627f\u62c5\u3002<\/p>\n<p>\u5c06\u4ee3\u7801\u6dfb\u52a0\u5230\u60a8\u7684 .htaccess \u6587\u4ef6<\/p>\n<p>\u901a\u8fc7\u5728.htaccess \u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u884c\uff0c\u60a8\u53ef\u4ee5\u9632\u6b62\u70ed\u94fe\u63a5\u5230\u60a8\u7684\u7f51\u7ad9\uff1a<\/p>\n<p>\u91cd\u5199\u5f15\u64ce\u5f00\u542f<\/p>\n<p>\u91cd\u5199\u6761\u4ef6 %{HTTP_REFERER} !^$<\/p>\n<p>RewriteCond %{HTTP_REFERER} !^http:\/\/(www.)? example.com \/.*$ [NC]<\/p>\n<p>RewriteRule .(gif|jpg)$ http:\/\/www.example.com\/hotlink.gif [ R,L]<\/p>\n<p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u5c06example.com\u66f4\u6539\u4e3a\u60a8\u7684\u7f51\u7ad9 URL\u3002\u8fd9\u4f1a\u5bfc\u81f4\u4efb\u4f55\u70ed\u94fe\u63a5\u56fe\u50cf\u65e0\u6cd5\u52a0\u8f7d\u3002\u60a8\u53ef\u4ee5\u66f4\u6539\u6700\u540e\u4e00\u884c\u4ee5\u6307\u5411\u60a8\u559c\u6b22\u7684\u4efb\u4f55\u56fe\u50cf\u3002\u6b64\u56fe\u50cf\u5e94\u8bf4\u660e\u60a8\u7684\u670d\u52a1\u5668\u4e0a\u7981\u7528\u4e86\u70ed\u94fe\u63a5\u3002<\/p>\n<p>\u8fd9\u662f\u53e6\u4e00\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<p>\u91cd\u5199\u5f15\u64ce\u5f00\u542f<\/p>\n<p>RewriteCond %{HTTP_REFERER} !^http: \/\/example.com .*$ [NC]<\/p>\n<p>RewriteCond %{HTTP_REFERER} !^http:\/\/ www.example.com .*$ [NC]<\/p>\n<p>RewriteRule .*.(gif|jpg|jpeg|bmp)$ http:\/\/www.example.com\/stophotlinking.jpg [ R,NC]<\/p>\n<p>\u60a8\u53ef\u4ee5\u66f4\u6539\u6700\u540e\u4e00\u884c\u4ee5\u6307\u5411\u60a8\u559c\u6b22\u7684\u4efb\u4f55\u56fe\u50cf\u3002\u6b64\u56fe\u50cf\u5e94\u8bf4\u660e\u60a8\u7684\u670d\u52a1\u5668\u4e0a\u7981\u7528\u4e86\u70ed\u94fe\u63a5\u3002<\/p>\n<p>\u5982\u679c\u60a8\u4e0d\u60f3\u91c7\u7528\u624b\u52a8\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u5728\u9762\u677f\u4e2d\u542f\u7528\u5b83\u6765\u9632\u6b62\u76d7\u94fe\u3002\u8981\u542f\u7528\uff0c\u8bf7\u5bfc\u822a\u5230Htaccess\/WebDAV\u9875\u3002\u5355\u51fb\u60a8\u7684\u57df\u5e76\u7ee7\u7eed\u6267\u884c\u542f\u7528\u6b64\u529f\u80fd\u7684\u6b65\u9aa4\u3002<\/p>\n<p>\u963b\u6b62\u7279\u5b9a\u57df<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u65e0\u6cd5\u52a0\u8f7d\u70ed\u94fe\u63a5\u6587\u4ef6\uff0c\u4f46\u4e0d\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u5982\u679c\u7ad9\u70b9example.com\u5305\u542b\u6307\u5411\u60a8\u7ad9\u70b9\u7684\u70ed\u94fe\u63a5\u56fe\u50cf\uff0c\u5b83\u5c06\u65e0\u6cd5\u5728\u5176\u7ad9\u70b9\u4e0a\u52a0\u8f7d\uff1a<\/p>\n<p>\u91cd\u5199\u5f15\u64ce\u5f00\u542f<\/p>\n<p>RewriteCond %{HTTP_REFERER} ^http:\/\/(www.)? \u793a\u4f8b.com (\/.*)*$ [NC,OR]<\/p>\n<p>\u91cd\u5199\u89c4\u5219 .(jpeg|JPEG|jpe|JPE|jpg|JPG|gif|GIF|png|PNG|mng|MNG)$ \u2013 [F]<\/p>\n<p>\u8981\u4fdd\u62a4\u5176\u4ed6\u8d44\u6e90\uff0c\u4f8b\u5982\u89c6\u9891\u548c\u97f3\u9891\u6587\u4ef6\uff0c\u8bf7\u5411RewriteRule\u62ec\u53f7\u5757\u6dfb\u52a0\u5176\u4ed6\u6269\u5c55\u3002<\/p>\n<p>\u4ec5\u5141\u8bb8\u7279\u5b9a\u57df<\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u4ec5\u5141\u8bb8\u7279\u5b9a\u7ad9\u70b9\u52a0\u8f7d\u5185\u5bb9\u3002\u4f8b\u5982\uff0c\u7ad9\u70b9example.com\u5305\u542b\u6240\u6709\u5185\u5bb9\u3002\u4ee5\u4e0b\u4ee3\u7801\u4ec5\u5141\u8bb8example.com\u548cdreamhost.com\u52a0\u8f7d\u5185\u5bb9\u3002\u5c1d\u8bd5\u8bf7\u6c42\u4efb\u4f55\u8d44\u6e90\u7684\u6240\u6709\u5176\u4ed6\u7ad9\u70b9\u90fd\u65e0\u6cd5\u52a0\u8f7d\u8d44\u6e90\uff0c\u4f46\u4e0d\u4f1a\u5f15\u53d1\u9519\u8bef\uff1a<\/p>\n<p>\u91cd\u5199\u5f15\u64ce\u5f00\u542f<\/p>\n<p>RewriteCond %{HTTP_REFERER} !^http:\/\/ (www.)?dreamhost.com (\/.*)*$ [NC]<\/p>\n<p>RewriteCond %{HTTP_REFERER} !^http:\/\/ (www.)?example.com (\/.*)*$ [NC]<\/p>\n<p>\u91cd\u5199\u6761\u4ef6 %{HTTP_REFERER} !^$<\/p>\n<p>\u91cd\u5199\u89c4\u5219 .(jpeg|gif|png)$ \u2013 [F]<\/p>\n<p>\u6b64\u5916\uff0c\u7531\u4e8e\u7528\u6237\u4ee3\u7406\u53ef\u80fd\u5e76\u4e0d\u603b\u662f\u6307\u5b9aHTTP_REFERER\u503c\uff0c\u5982\u679cHTTP_REFERER\u503c\u5305\u542b\u7a7a\u767d\u5b57\u7b26\u4e32\uff0c\u5219RewriteCond %{HTTP_REFERER} !^$\u884c\u5141\u8bb8\u8bf7\u6c42\u901a\u8fc7\u3002\u63a8\u8350\u76f8\u5173\u9605\u8bfb\uff1a<a href=\"https:\/\/cn.raksmart.com\/blog\/website\/seo\/1016.html\">\u300a\u5173\u4e8erobotstxt\u6587\u4ef6\u7684SEO\u4f18\u5316\u300b<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u70ed\u94fe\u63a5\u6216\u5e26\u5bbd\u7a83\u53d6\u662f\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\u3002\u5f53\u4eba\u4eec\u94fe\u63a5\u5230\u4e0d\u540c\u72ec\u7acb\u670d\u52a1\u5668\u4e0a\u7684\u6587\u4ef6\u548c\u56fe\u50cf\u5e76\u5c06\u5b83\u4eec\u663e\u793a\u5728\u4ed6\u4eec\u81ea\u5df1\u7684\u7f51\u7ad9\u2026 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[797,860,861],"class_list":["post-1864","post","type-post","status-publish","format-standard","hentry","category-knowledge","tag-htaccess","tag-860","tag-861"],"_links":{"self":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/1864","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/comments?post=1864"}],"version-history":[{"count":0,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/1864\/revisions"}],"wp:attachment":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/media?parent=1864"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/categories?post=1864"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/tags?post=1864"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}