{"id":1887,"date":"2013-04-22T16:50:41","date_gmt":"2013-04-22T08:50:41","guid":{"rendered":"https:\/\/sdeno.com\/?p=1887"},"modified":"2013-04-22T17:23:59","modified_gmt":"2013-04-22T09:23:59","slug":"vps%e7%8b%ac%e7%ab%8b%e6%9c%8d%e5%8a%a1%e5%99%a8%e8%ae%be%e7%bd%ae301%e8%b7%b3%e8%bd%ac","status":"publish","type":"post","link":"https:\/\/sdeno.com\/?p=1887","title":{"rendered":"vps\u72ec\u7acb\u670d\u52a1\u5668\u8bbe\u7f6e301\u8df3\u8f6c"},"content":{"rendered":"<p>\u505a301\u8df3\u8f6c\u8fd8\u8981\u5c06\u7f51\u7ad9\u505a\u6210\u4f2a\u9759\u6001\uff0c\u8fd9\u91cc\u4e0d\u7ba1\u662f\u4e0d\u662f\u8981\u4f2a\u9759\u6001\u624d\u80fd\u5b9e\u73b0\u8df3\u8f6c\u81f3\u5c11\u628a\u7f51\u7ad9\u8bbe\u7f6e\u6210\u4f2a\u9759\u6001\u5bf9seo\u6709\u5e2e\u52a9\uff0c\u81f3\u4e8e\u4e3a\u4ec0\u4e48\u505a301\u8df3\u8f6c\u94fe\u63a5\u5230<a href=\"https:\/\/sdeno.com\/wordpress%E5%A6%82%E4%BD%95%E5%81%9A301%E8%B7%B3%E8%BD%AC\/\">wordpress\u5982\u4f55\u505a301\u8df3\u8f6c<\/a>\u3002<br \/>\n\u4e0b\u9762\u5c31\u7b80\u5355\u8bf4\u4e0b\u5728IIS\u548capache\u4f2a\u88c5\u9759\u6001\u4e0b\u5b9e\u73b0301\u8df3\u8f6c\u7684\u65b9\u6cd5\u3002<br \/>\n<span style=\"color: #ff0000;\">windows IIS\u670d\u52a1\u5668\uff1a<\/span><br \/>\n\u5982\u679c\u60a8\u662fwindows\u7cfb\u7edf\u7684\uff0c\u5728http:\/\/downinfo.myhostadmin.net\/rewrite3.rar \u4e0b\u8f7d\u4e00\u4e2a\u4f2a\u9759\u6001\u8bbe\u7f6e\u5b89\u88c5\u5305\uff0c\u5b89\u88c5\u524d\u8bf7\u5148\u9605\u8bfb\u8bf4\u660e\u6587\u6863\u3002\u5b89\u88c5\u540e\u4f1a\u751f\u6210\u4e00\u4e2aC:\\rewrite3 \u7684\u6587\u4ef6\u5939\uff0c\u76f4\u63a5\u4fee\u6539\u6587\u4ef6\u5939\u91cc\u7684httpd.conf\u6587\u4ef6\u5373\u53ef\uff0c\u53ea\u9700\u4fee\u6539\u4ee5\u4e0b\u5185\u5bb9\u4e2d\u7684\u7f51\u5740\u5373\u53ef\uff1a<\/p>\n<p>#301\u8bbe\u7f6e\uff0c\u6b64\u8bbe\u7f6e\u60c5\u51b5\u4e0bcctv.com\/aa.htm \u4f1a301\u8df3\u81f3www.cctv.com\/aa.htm\uff0c\u5c06cctv.com\u66ff\u6362\u4e3a\u60a8\u81ea\u5df1\u7684\u57df\u540d\u5c31\u80fd\u5b9e\u73b0\u81ea\u5df1\u7684\u57df\u540d\u7684301<br \/>\nRewriteCond %{HTTP:Host} ^cctv.com$<br \/>\nRewriteRule (.*) http:\/\/www.cctv.com$1 [NC,R=301]<\/p>\n<p><span style=\"color: #ff0000;\">linux apache\u670d\u52a1\u5668\uff1a<\/span><br \/>\n\u65b9\u6cd5\u4e00\uff1a\u5982\u679c\u60a8\u662flinux\u7cfb\u7edf\u7684\uff0c\u5728\u60a8\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\u65b0\u5efa\u4e00\u4e2a.htaccess\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u3002\u82e5\u4ee5\u524d\u5df2\u7ecf\u5b58\u5728\u8be5\u6587\u4ef6\u5219\u76f4\u63a5\u5728\u6587\u4ef6\u5934\u90e8\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\u3002<\/p>\n<p>[code]&lt;IfModule mod_rewrite.c&gt;<\/p>\n<p>RewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} !^www.abc.com$ [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.abc.com\/$1 [R=301,L]<\/p>\n<p>&lt;\/IfModule&gt;[\/code]<\/p>\n<p>#\u8bf4\u660e\uff1awww.abc.com\u8bf7\u66ff\u6362\u4e3a\u60a8\u65b0\u7684\u76ee\u6807\u57df\u540d\uff0c\u8fd9\u4e2a\u89c4\u5219\u5c06\u4f1a\u5c06\u60a8\u7684\u4e3b\u673a\u7ed1\u5b9a\u7684\u6240\u6709\u57df\u540d301\u91cd\u5b9a\u5411\u5230www.abc.com<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff1a<br \/>\n\u6848\u4f8b\uff1a<br \/>\n\u8bbf\u95ee http:\/\/xobm.com \uff0c\u5219\u8df3\u8f6c\u5230 http:\/\/www.xobm.com\u3002<br \/>\n\u8bbf\u95ee http:\/\/www.xobm.com \uff0c\u5219\u4e0d\u518d\u8df3\u8f6c\uff0c\u76f4\u63a5\u8bbf\u95ee\u3002<br \/>\n\u5373\u4f7f\u7528 http:\/\/www.xobm.com\u4f5c\u4e3a\u7f51\u7ad9\u7684\u4e3b\u7f51\u5740\u3002<br \/>\n\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>\n\u7b2c\u4e00\u6b65\uff1aApache\u865a\u62df\u673a\u914d\u7f6e\uff1a<br \/>\n[code]&lt;VirtualHost *:80&gt;<br \/>\nServerAdmin mac@xobm.com<br \/>\nDocumentRoot \u201c\/var\/www\/www.xobm.com\/\u201d<br \/>\nServerName www.xobm.com<br \/>\nServerAlias xobm.com \/\/\u8fd9\u53e5\u662f\u5173\u952e\uff0c\u914d\u7f6e\u522b\u540d<br \/>\nErrorLog \u201clogs\/dummy-host2.xobm.com-error.log\u201d<br \/>\nCustomLog \u201clogs\/dummy-host2.xobm.com-access.log\u201d common<br \/>\n&lt;Directory \/&gt;<br \/>\nAllowOverride All<br \/>\nAllow from all<br \/>\n&lt;\/Directory&gt;<br \/>\n&lt;\/VirtualHost&gt;[\/code]<br \/>\n\u7b2c\u4e8c\u6b65\uff1aHTACCESS\u5199\u6cd5<br \/>\n[code]&lt;IfModule mod_rewrite.c&gt;<br \/>\nRewriteEngine On<br \/>\nRewriteCond %{HTTP_HOST} ^xobm.com [NC]<br \/>\nRewriteRule ^(.*) http:\/\/www.xobm.com\/ [L]<br \/>\nRewriteCond %{REQUEST_FILENAME} !-d<br \/>\nRewriteCond %{REQUEST_FILENAME} !-f<br \/>\nRewriteRule ^(.*)$ index.php?url=$1 [QSA,L]<br \/>\n&lt;\/IfModule&gt;[\/code]<\/p>\n<p>\u5176\u5b9e\u505a301\u8df3\u8f6c\u7684\u65b9\u6cd5\u8fd8\u633a\u591a\u7684\uff0c\u8fd8\u6709\u4e00\u4e2a\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u57df\u540d\u5546\u505aurl\u8f6c\u53d1\uff0c<\/p>\n<p><a href=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/04\/urlzhuanfa.jpg\"><figure class=\"mdx-lazyload-container\" style=\"max-width:333px\"><div style=\"padding-top:38.138138138138%\"><\/div><div class=\"mdx-img-loading-sp mdui-valign\"><div><div class=\"mdui-spinner\"><\/div><\/div><\/div><img width=\"333\" height=\"127\" class=\"alignnone size-full wp-image-1891 lazyload\" title=\"urlzhuanfa\" src=\"data:image\/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==\" data-src=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/04\/urlzhuanfa.jpg\" alt=\"urlzhuanfa\" data-srcset=\"https:\/\/sdeno.com\/wp-content\/uploads\/2013\/04\/urlzhuanfa.jpg 333w, https:\/\/sdeno.com\/wp-content\/uploads\/2013\/04\/urlzhuanfa-300x114.jpg 300w\" sizes=\"auto, (max-width: 333px) 100vw, 333px\"><\/figure><\/a><br \/>\n\u4f46\u662f\u8fd9\u4e2a\u65b9\u6cd5\u57df\u540d\u5546\u662f\u8981\u6536\u8d39\u7684\u3002<\/p>\n<p>\u8fd8\u6709\u4e00\u79cd\u5c31\u662f\u5229\u7528\u4ee3\u7801\u5b9e\u73b0\u8df3\u8f6c\u529f\u80fd\uff1a<\/p>\n<p>1\u3001IIS\u4e0b301\u8bbe\u7f6e<br \/>\nInternet\u4fe1\u606f\u670d\u52a1\u7ba1\u7406\u5668 -&gt; \u865a\u62df\u76ee\u5f55 -&gt; \u91cd\u5b9a\u5411\u5230URL\uff0c\u8f93\u5165\u9700\u8981\u8f6c\u5411\u7684\u76ee\u6807URL\uff0c\u5e76\u9009\u62e9\u201c\u8d44\u6e90\u7684\u6c38\u4e45\u91cd\u5b9a\u5411\u201d\u3002<br \/>\n2\u3001ASP\u4e0b\u7684301\u8f6c\u5411\u4ee3\u7801<br \/>\n[code]&lt;%@ Language=VBScript %&gt;<br \/>\n&lt;%<br \/>\nResponse.Status=\u201d301 Moved Permanently\u201d<br \/>\nResponse.AddHeader \u201cLocation\u201d, \u201chttp:\/\/www.xxx.com\/articles\/301\/\u201d<br \/>\n%&gt;[\/code]<br \/>\n3\u3001ASP.Net\u4e0b\u7684301\u8f6c\u5411\u4ee3\u7801<br \/>\n[code]&lt;script runat=\u201dserver\u201d&gt;<br \/>\nprivate void Page_Load(object sender, System.EventArgs e)<br \/>\n{<br \/>\nResponse.Status = \u201c301 Moved Permanently\u201d;<br \/>\nResponse.AddHeader(\u201dLocation\u201d,\u201dhttp:\/\/www.xxx.com\/articles\/301\/\u201c);<br \/>\n}<br \/>\n&lt;\/script&gt;[\/code]<br \/>\n4\u3001PHP\u4e0b\u7684301\u8f6c\u5411\u4ee3\u7801<br \/>\n[code]header(\u201dHTTP\/1.1 301 Moved Permanently\u201d);<br \/>\nheader(\u201dLocation: http:\/\/www.xxx.com\/articles\/301\/\u201d);<br \/>\nexit();[\/code]<br \/>\n5\u3001CGI Perl\u4e0b\u7684301\u8f6c\u5411\u4ee3\u7801<br \/>\n[code]$q = new CGI;<br \/>\nprint $q-&gt;redirect(\u201dhttp:\/\/www.new-url.com\/\u201d);[\/code]<br \/>\n6\u3001JSP\u4e0b\u7684301\u8f6c\u5411\u4ee3\u7801<br \/>\n[code]&lt;%<br \/>\nresponse.setStatus(301);<br \/>\nresponse.setHeader( \u201cLocation\u201d, \u201chttp:\/\/www.xxx.com\/\u201d );<br \/>\nresponse.setHeader( \u201cConnection\u201d, \u201cclose\u201d );<br \/>\n%&gt;[\/code]<br \/>\n7\u3001Apache\u4e0b301\u8f6c\u5411\u4ee3\u7801<br \/>\n\u65b0\u5efa.htaccess\u6587\u4ef6\uff0c\u8f93\u5165\u4e0b\u5217\u5185\u5bb9\uff08\u9700\u8981\u5f00\u542fmod_rewrite\uff09\uff1a<br \/>\n1\uff09\u5c06\u4e0d\u5e26WWW\u7684\u57df\u540d\u8f6c\u5411\u5230\u5e26WWW\u7684\u57df\u540d\u4e0b<br \/>\nOptions +FollowSymLinks<br \/>\nRewriteEngine on<br \/>\nRewriteCond %{HTTP_HOST} ^lesishu.cn [NC]<br \/>\nRewriteRule ^(.*)$ http:\/\/www.xxx.com\/$1 [L,R=301]<br \/>\n2\uff09\u91cd\u5b9a\u5411\u5230\u65b0\u57df\u540d<br \/>\nOptions +FollowSymLinks<br \/>\nRewriteEngine on<br \/>\nRewriteRule ^(.*)$ http:\/\/www.xxx.com\/$1 [L,R=301]<br \/>\n3\uff09\u4f7f\u7528\u6b63\u5219\u8fdb\u884c301\u8f6c\u5411\uff0c\u5b9e\u73b0\u4f2a\u9759\u6001<br \/>\nOptions +FollowSymLinks<br \/>\nRewriteEngine on<br \/>\nRewriteRule ^news-(.+)\\.html$ news.php?id=$1<br \/>\n\u5c06news.php?id=123\u8fd9\u6837\u7684\u5730\u5740\u8f6c\u5411\u5230news-123.html<br \/>\n8\u3001Apache\u4e0bvhosts.conf\u4e2d\u914d\u7f6e301\u8f6c\u5411<br \/>\n\u4e3a\u5b9e\u73b0URL\u89c4\u8303\u5316\uff0cSEO\u901a\u5e38\u5c06\u4e0d\u5e26WWW\u7684\u57df\u540d\u8f6c\u5411\u5230\u5e26WWW\u57df\u540d\uff0cvhosts.conf\u4e2d\u914d\u7f6e\u4e3a\uff1a<br \/>\n&lt;VirtualHost *:80&gt;<br \/>\nServerName www.xxx.com<br \/>\nDocumentRoot \/home\/lesishu<br \/>\n&lt;\/VirtualHost&gt;<br \/>\n&lt;VirtualHost *:80&gt;<br \/>\nServerName lesishu.cn<br \/>\nRedirectMatch permanent ^\/(.*) http:\/\/www.xxx.com\/$1<br \/>\n&lt;\/VirtualHost&gt;<br \/>\nApache\u4e0b\u9664\u4e86\u4ee5\u4e0a2\u79cd\u65b9\u6cd5\uff0c\u8fd8\u6709\u5176\u4ed6\u914d\u7f6e\u65b9\u6cd5\u548c\u53ef\u9009\u53c2\u6570<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u505a301\u8df3\u8f6c\u8fd8\u8981\u5c06\u7f51\u7ad9\u505a\u6210\u4f2a\u9759\u6001\uff0c\u8fd9\u91cc\u4e0d\u7ba1\u662f\u4e0d\u662f\u8981\u4f2a\u9759\u6001\u624d\u80fd\u5b9e\u73b0\u8df3\u8f6c\u81f3\u5c11\u628a\u7f51\u7ad9\u8bbe\u7f6e\u6210\u4f2a\u9759\u6001\u5bf9seo\u6709\u5e2e\u52a9\uff0c\u81f3\u4e8e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"close","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1887","post","type-post","status-publish","format-standard","hentry","category-11"],"_links":{"self":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/1887","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1887"}],"version-history":[{"count":0,"href":"https:\/\/sdeno.com\/index.php?rest_route=\/wp\/v2\/posts\/1887\/revisions"}],"wp:attachment":[{"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sdeno.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}