<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>廖文亮网站运营博客 &#187; 301</title>
	<atom:link href="http://blog.izzj.com/tag/301/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.izzj.com</link>
	<description>用户需要的 我们给予的……</description>
	<lastBuildDate>Wed, 01 Feb 2012 11:28:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>301跳转之网站动静态页面处理方式</title>
		<link>http://blog.izzj.com/85</link>
		<comments>http://blog.izzj.com/85#comments</comments>
		<pubDate>Fri, 17 Sep 2010 01:46:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分类]]></category>
		<category><![CDATA[301]]></category>

		<guid isPermaLink="false">http://blog.izzj.com/?p=85</guid>
		<description><![CDATA[301跳转之网站动静态页面处理方式]]></description>
			<content:encoded><![CDATA[<p>动态页面进行301重定向,权重转移我想大家都很清楚了,代码如下,重温一下.</p>
<p class="code"><code>&lt;!--ASP：--&gt;<br />
&lt;%<br />
Response.Status="301 Moved Permanently"<br />
Response.AddHeader "Location","http://www.izzj.com"<br />
Response.End<br />
%&gt;</p>
<p>&lt;!--PHP：--&gt;<br />
&lt;?php<br />
if ( $_SERVER['SERVER_NAME'] == 'izzj.com'){<br />
header("HTTP/1.1 301 Moved Permanently");<br />
header("Location: http://www.izzj.com");<br />
exit();<br />
}<br />
?&gt;<br />
</code></p>
<p><strong>如果我想把 http://izzj.com 权重转移到 http://www.izzj.com 该怎么操作呢?</strong></p>
<p>很简单,情况下面代码.</p>
<p class="code"><code>&lt;!--ASP：--&gt;<br />
&lt;%<br />
if Request.ServerVariables("Http_Host") ="izzj.com" then<br />
Response.Status="301 Moved Permanently"<br />
Response.AddHeader "Location","http://www.izzj.com"<br />
Response.End<br />
end if<br />
%&gt;</p>
<p>&lt;!--PHP：--&gt;<br />
&lt;?php<br />
if ( $_SERVER['SERVER_NAME'] == 'izzj.com'){<br />
header("HTTP/1.1 301 Moved Permanently");<br />
header("Location: http://www.izzj.com");<br />
exit();<br />
}<br />
?&gt;</p>
<p>&lt;b&gt;我想做完美的301跳转,也就是子页面跳转到对应的子页面怎么操作呢?&lt;/b&gt;&lt;br&gt;<br />
&lt;b&gt;同级域名跳转例如:<br />
http://www.izzj.com/Record/69.html<br />
http://www.izzj.com/Record/69.html&lt;br&gt;<br />
</code> </p>
<p>已经有网友成功验证,这个方法是可行的.效果比动态的301跳转来的慢一些.</p>
<p class="code"><code>&lt;%<br />
netpath = "http://www.izzj.com"<br />
netpath = netpath&amp;Request.ServerVariables("PATH_INFO")<br />
response.write netpath<br />
Response.Status="301 Moved Permanently"<br />
Response.AddHeader "Location",netpath<br />
Response.End<br />
%&gt;<br />
</code></p>
<p>非同级域名跳转例如:<br />
<a href="http://izzj.com/Record/69.html" target="_blank">http://izzj.com/Record/69.html</a><br />
http://www.izzj.com/Record/69.html<br />
也不难,如下.</p>
<p class="code"><code>&lt;%<br />
Dim dm,sn<br />
dm=Request.ServerVariables("Server_name")  '获取域名<br />
'这里的3是指www的长度<br />
if left(dm,3)&lt;&gt;"www" then<br />
Response.Status="301 Moved Permanently"<br />
Response.AddHeader "Location", GetUrl()<br />
Response.End<br />
end if</p>
<p>'获取当前Url参数的函数<br />
Function GetUrl()<br />
  Dim ScriptAddress,Servername,qs<br />
  ScriptAddress = CStr(Request.ServerVariables("SCRIPT_NAME"))<br />
  Servername = CStr(Request.ServerVariables("Server_Name"))<br />
  qs=Request.QueryString<br />
  if qs&lt;&gt;"" then<br />
  GetUrl ="http://www."&amp; Servername &amp; ScriptAddress &amp;"?"&amp;qs<br />
  else<br />
  GetUrl ="http://www."&amp; Servername &amp; ScriptAddress<br />
  end if<br />
End Function<br />
%&gt;<br />
</code></p>
<p><strong>在我们遇到了静态页面的时候如何做权重转移呢?</strong></p>
<p>很多时候因为网站改版或者什么其他原因,有些静态页面已经有很高的PR了,如何把这些高PR的静态页面转移到其他网页上呢.</p>
<p>需要对一些静态页面进行转移,一个网页能否算是成功读取,服务器会给客户端返回一个成功读取的参数,一般是200错误.说到这里可能有些朋友会有点晕,为什么是错误呢,这里指的200错误是指服务器返回值,例如:当打开某网页,网页不存在时会返回404错误,权限不足时会返回401错误等等.</p>
<p>这里做的静态页面权重转移就是要利用404错误.</p>
<p>建一个error.asp文件.指定404错误跳转到error.asp文件.</p>
<p>然后error.asp文件分析网址,得到旧网址,再通过上面的301代码跳转到新的网址.</p>
<p><strong>还有一种方法就简单点.直接用元描述跳转</strong></p>
<p>[CODE_LITE]<br />
&lt;meta http-equiv=&#8221;refresh&#8221; content=&#8221;10;URL=http://www.izzj.com&#8221;&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.izzj.com/85/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>廖文亮：更换域名不用愁,完美首页内页实现301转移</title>
		<link>http://blog.izzj.com/49</link>
		<comments>http://blog.izzj.com/49#comments</comments>
		<pubDate>Thu, 01 Apr 2010 10:04:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[seo]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[域名]]></category>

		<guid isPermaLink="false">http://blog.izzj.com/?p=49</guid>
		<description><![CDATA[关于301的一些事]]></description>
			<content:encoded><![CDATA[<p>问题：<br />
如果一个网站拥有两个域名：domain1.com和domain2.com。</p>
<p>在网站运营前期，主推domain1.com，但发展到中期，由于品牌或产品定位的原因，domain1.com这个域名不再适合当前情况，要更换成domain2.com。</p>
<p>作为SEO,我们肯定推荐使用301跳转，当用户访问domain1.com时，自动引导用户进入新域名domain2.com，可以通过程序或域名跳转实现301跳转，这样可以将旧域名PR传递到新域名。</p>
<p>但是如果用户收藏了旧域名的某个内容页（譬如：domain1.com/content/20070808.html），通过域名跳转直接引导到 domain2.com首页恐怕会产生较差用户体验，特别是对未及时获知域名更换的用户；最好方式是实现通配，动态的将旧域名某个内页跳转到新域名相同页 面的URL，那如何用技术手段实现新旧内页URL之间的301跳转？？？</p>
<p>即：从domain1.com/content/20070808.html跳转到domain2.com/content/20070808.html，并使浏览器返回301代码</p>
<p>例如：<br />
大旗网域名由chinabbs.com换成daqi.com<br />
博客网域名由blogchina.com换成bokee.com</p>
<p>——————————————————————————–</p>
<p>PHP下的实现方式（参考）：<br />
.htaccess文件代码如下（izzj.com的.htaccess如此设置）：<br />
Options +FollowSymlinks<br />
RewriteEngine on<br />
rewritecond %{http_host} ^izzj.com [nc]<br />
rewriterule ^(.*)$ <a href="http://www.izzj.com/" target="_blank">http://www.izzj.com/</a>$1 [r=301,nc]</p>
<p>注 释1：如果用户访问<a href="http://izzj.com/" target="_blank">http://izzj.com/</a>，则跳转至<a href="http://www.izzj.com/" target="_blank">http://www.izzj.com</a>，且返回301状态码；当用 户访问<a href="http://izzj.com/post/301.htm" target="_blank">http://izzj.com/post/301.htm</a>，则跳转至http: //www.izzj.com/post/301.htm，并返回301状态码。</p>
<p>注释2：测试URL：<a href="http://www.xxx.com/" target="_blank">http://www.xxx.com/</a>，你可以访问<a href="http://www.xxx.com/post/301.htm" target="_blank">http://www.xxx.com/post/301.htm</a></p>
<p>我在xxx.com下配置了.htaccess文件，使其301跳转至<a href="http://www.izzj.com/post/301.htm" target="_blank">http://www.izzj.com/post/301.htm</a></p>
<p>我的.htaccess配置实现了由主域名（izzj.com）301跳转至二级域名（<a href="http://www.izzj.com/" target="_blank">www.izzj.com</a>）；<br />
结论：<br />
Options +FollowSymlinks<br />
RewriteEngine on<br />
rewritecond %{http_host} ^<a href="http://www.domain1.com/" target="_blank">www.domain1.com</a> [nc]<br />
rewriterule ^(.*)$ <a href="http://www.domain2.com/" target="_blank">http://www.domain2.com/</a>$1 [r=301,nc]</p>
<p>——————————————————————————–</p>
<p>ASP脚本实现301跳转的方法：</p>
<p>&lt;%<br />
if request.ServerVariables(”HTTP_HOST”)=”domain1.com” or request.ServerVariables(”HTTP_HOST”)=”<a href="http://www.domain1.com/" target="_blank">www.domain1.com</a>” then<br />
if Request.ServerVariables(”QUERY_STRING”)&lt;&gt;”&#8221; then p=”?”<br />
Response.Status=”301 Moved Permanently”<br />
Response.AddHeader “Location”,”<a href="http://www.domain2.com/" target="_blank">http://www.domain2.com</a>”&amp;Request.ServerVariables(”SCRIPT_NAME”)&amp;p&amp;Request.ServerVariables(”QUERY_STRING”)<br />
Response.End<br />
end if<br />
%&gt;</p>
<p>一、if request.ServerVariables(”HTTP_HOST”)=”admini5.cn” or request.ServerVariables(”HTTP_HOST”)=”<a href="http://www.admini5.cn/" target="_blank">www.admini5.cn</a>” Then<br />
当发现客户是用旧域名来访问网站的，则进入转向流程<br />
二、if Request.ServerVariables(”QUERY_STRING”)&lt;&gt;”&#8221; then p=”?”<br />
Response.Status=”301 Moved Permanently”<br />
当发现页面是含参数的，则加入“？”<br />
发送转向的HTTP状态码301<br />
三、 Response.AddHeader “Location”,”<a href="http://www.admini5.com/" target="_blank">http://www.admini5.com</a>”&amp;Request.ServerVariables(”SCRIPT_NAME”)&amp;p&amp;Request.ServerVariables(”QUERY_STRING”)<br />
当不含参数时，变量P和REQUEST.ServerVariables都为空<br />
当含有参数时，则生成被请求页的的相对URL。这样就达到了一种效果：无论客户访问哪一页，都会自动转向到另一个页面的同一文件里且包含同一个参数。</p>
<p>——————————————————————————–<br />
win主机实现方法</p>
<p>$S 将请求的 URL 的后缀传递给新的 URL。后缀是用重定向的 URL 代替之后，初始 URL 中所保留的部分。</p>
<p>　　如果未设置 EXACT_DESTINATION 标志，则结果目标 URL 的名称将具有所请求文件的名称(作为文件夹名称)以及文件名本身。</p>
<p>　　$Q 将初始 URL 中的参数(如 querystring 参数)传递至新的 URL，包括问号 (?)。</p>
<p>　　具体的操作为。</p>
<p>　　打开IIS.新建网站。绑定要做转向的米。如我的<a href="http://www.xxx.cn/" target="_blank">www.xxx.cn</a> 然后右键，属性，主目录。</p>
<p>　　以下为引用的内容：</p>
<p>　　此资源的内容来自：选择 重新定向到URL(U)</p>
<p>　　重新定向到(C) 这里输入我的新域名 <a href="http://www.xxx.net/" target="_blank">http://www.xxx.net</a>$S$Q (注意，我后边加上了参数$S$Q)</p>
<p>　　客户端重新定向到: 选择 上边输入的准确 URL(X) 和资源的永久重新定向(H)</p>
<p>　　然后确定就行了。</p>
<p>　　测试一下。在地址栏里输入<a href="http://www.xxx.cn/" target="_blank">http://www.xxx.cn</a>   自动跳转到 <a href="http://www.xxx.net/" target="_blank">http://www.xxx.net</a></p>
<p>　　在试下内页的跳转。收入<a href="http://www.xxx.cn/tv/hk_tw/ht_13938.html" target="_blank">http://www.xxx.cn/tv/hk_tw/ht_13938.html</a> 自动跳转到<a href="http://www.xxx.net/tv/hk_tw/ht_13938.html" target="_blank">http://www.xxx.net/tv/hk_tw/ht_13938.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.izzj.com/49/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

