{"id":607,"date":"2012-11-06T20:52:27","date_gmt":"2012-11-06T12:52:27","guid":{"rendered":"http:\/\/www.spendl.com\/?p=607"},"modified":"2015-06-24T23:22:45","modified_gmt":"2015-06-24T15:22:45","slug":"apache%e7%8e%af%e5%a2%83%e5%88%a9%e7%94%a8-htaccess%e6%96%87%e4%bb%b6%e5%ae%9e%e7%8e%b0301%e9%87%8d%e5%ae%9a%e5%90%91","status":"publish","type":"post","link":"https:\/\/www.spendl.com\/?p=607","title":{"rendered":"apache\u73af\u5883\u5229\u7528.htaccess\u6587\u4ef6\u5b9e\u73b0301\u91cd\u5b9a\u5411"},"content":{"rendered":"<p>\u51fa\u4e8eSEO\u3001PR\u503c\u4f20\u9012\u3001\u7f51\u5740\u8f6c\u6362\u7684\u76ee\u7684\uff0c\u5728\u7f51\u7ad9\u521d\u5efa\u548c\u7f51\u7ad9\u8fc1\u79fb\u65f6\u6211\u4eec\u90fd\u9700\u8981\u4f7f\u7528301\u91cd\u5b9a\u5411\uff0c\u901a\u5e38\u5305\u62ec\u57df\u540d\u5bf9\u57df\u540d\uff0c\u76ee\u5f55\u5bf9\u76ee\u5f55\u548c\u4e00\u4e2a\u72ec\u7acb\u7f51\u5740\u5bf9\u53e6\u4e00\u4e2a\u72ec\u7acb\u7f51\u5740\u7684\u91cd\u5b9a\u5411\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u5728\u8bbe\u7f6e301\u91cd\u5b9a\u5411\u4e4b\u524d\u52a1\u5fc5\u5907\u4efd\u76f8\u5e94\u76ee\u5f55\u4e0b\u7684.htaccess\u6587\u4ef6\u3002<br \/>\n<strong>1.\u91cd\u5b9a\u5411domain.com\u5230www.domain.com<\/strong><br \/>\n\u8fd9\u79cd\u91cd\u5b9a\u5411\u65e8\u5728\u4f7f\u57df\u540d\u552f\u4e00\uff0c\u662f\u7f51\u7ad9SEO\u5fc5\u987b\u8981\u505a\u7684\uff0c\u540e\u9762\u91cd\u5b9a\u5411www.domain.com\u5230domain.com\u4e5f\u662f\u51fa\u4e8e\u540c\u6837\u7684\u539f\u56e0\uff0c\u53ea\u662f\u5f62\u5f0f\u4e0d\u540c\u3002<br \/>\n\u6253\u5f00.htaccess\u6587\u4ef6\uff0c\u52a0\u5165\u4ee5\u4e0b\u89c4\u5219\u3002(\u4e0b\u9762\u7684\u89c4\u5219\u662f\u9488\u5bf9\u4e3b\u57df\u540d\u7684\uff0c\u5b50\u57df\u540d\u8981\u4fee\u6539)<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:600px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/><\/div><\/td><td><div class=\"text codecolorer\">RewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.domain.com\/$1 [L,R=301]<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><strong>2.\u91cd\u5b9a\u5411www.domain.com\u5230domain.com<\/strong><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:600px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/><\/div><\/td><td><div class=\"text codecolorer\">RewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} !^domain.com$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/domain.com\/$1 [L,R=301]<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><strong>3.\u91cd\u5b9a\u5411olddomain.com\u5230www.newdomain.com<\/strong><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:600px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/><\/div><\/td><td><div class=\"text codecolorer\">RewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} !olddomain.com$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.newdomain.com\/$1 [L,R=301]<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><strong>4.\u91cd\u5b9a\u5411olddomain.com to newdomain.com<\/strong><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:600px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/><\/div><\/td><td><div class=\"text codecolorer\">RewriteEngine On<br \/>\nRewriteBase \/<br \/>\nRewriteCond %{HTTP_HOST} !olddomain.com$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/newdomain.com\/$1 [L,R=301]<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p><strong>5.\u91cd\u5b9a\u5411domain.com\/file\/file.php \u5230 otherdomain.com\/otherfile\/other.php<\/strong><\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:600px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/><\/div><\/td><td><div class=\"text codecolorer\">RewriteCond %{HTTP_HOST} ^www.domain.com$<br \/>\nRewriteRule ^file\/file.php$ http:\/\/www.otherdomain.com\/otherfile\/other.php [R=301,L]<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u51fa\u4e8eSEO\u3001PR\u503c\u4f20\u9012\u3001\u7f51\u5740\u8f6c\u6362\u7684\u76ee\u7684\uff0c\u5728\u7f51\u7ad9\u521d\u5efa\u548c\u7f51\u7ad9\u8fc1\u79fb\u65f6\u6211\u4eec\u90fd\u9700\u8981\u4f7f\u7528301\u91cd\u5b9a\u5411\uff0c\u901a\u5e38\u5305\u62ec\u57df\u540d\u5bf9\u57df\u540d\uff0c\u76ee\u5f55\u5bf9\u76ee\u5f55\u548c\u4e00\u4e2a\u72ec\u7acb\u7f51\u5740\u5bf9\u53e6\u4e00\u4e2a\u72ec\u7acb\u7f51\u5740\u7684\u91cd\u5b9a\u5411\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u5728\u8bbe\u7f6e301\u91cd\u5b9a\u5411\u4e4b\u524d\u52a1\u5fc5\u5907\u4efd\u76f8\u5e94\u76ee\u5f55\u4e0b\u7684.htaccess\u6587\u4ef6\u3002<\/p>\n<p><strong>1.\u91cd\u5b9a\u5411domain.com\u5230www.domain.c<\/strong><\/p>\n<div class=\"clear-float\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[54],"tags":[244,245,243,246],"views":10796,"_links":{"self":[{"href":"https:\/\/www.spendl.com\/index.php?rest_route=\/wp\/v2\/posts\/607"}],"collection":[{"href":"https:\/\/www.spendl.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.spendl.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.spendl.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.spendl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=607"}],"version-history":[{"count":3,"href":"https:\/\/www.spendl.com\/index.php?rest_route=\/wp\/v2\/posts\/607\/revisions"}],"predecessor-version":[{"id":609,"href":"https:\/\/www.spendl.com\/index.php?rest_route=\/wp\/v2\/posts\/607\/revisions\/609"}],"wp:attachment":[{"href":"https:\/\/www.spendl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=607"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.spendl.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=607"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.spendl.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=607"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}