<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Heck's  Blog]]></title> 
<link>https://www.heckjj.com/index.php</link> 
<description><![CDATA[一瞬间的决定，往往可以改变很多，事实上，让自己成功的往往不是知识，是精神！ 如果你总是为自己找借口，那只好让成功推迟。执行力，今天！]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Heck's  Blog]]></copyright>
<item>
<link>https://www.heckjj.com/supportness-htaccess-host-301-redirect/</link>
<title><![CDATA[php asp asp.net jsp不支持.htaccess怎么做301重定向]]></title> 
<author>Heck &lt;@hecks.tk&gt;</author>
<category><![CDATA[学习心得]]></category>
<pubDate>Sun, 26 Sep 2010 10:37:55 +0000</pubDate> 
<guid>https://www.heckjj.com/supportness-htaccess-host-301-redirect/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-family: 微软雅黑;">我们常常通过301重定向可促进搜索引擎优化效果，下面请看说细的说明和给出来的代码。从搜索引擎优化角度出发，301重定向是网址重定向最为可行的一种办法。当网站的域名发生变更后，搜索引擎只对新网址进行索引，同时又会把旧地址下原有的外部链接如数转移到新地址下，从而不会让网站的排名因为网址变更而收到丝毫影响。同样，在使用301永久性重定向命令让多个域名指向网站主域时，亦不会对网站的排名产生任何负面影响。<br/><br/>　　302重定向可影响搜索引擎优化效果，迄今为止，能够对302重定向具备优异处理能力的只有Google。也就是说，在网站使用302重定向命令将其它域名指向主域时，只有Google会把其它域名的链接成绩计入主域，而其它搜索引擎只会把链接成绩向多个域名分摊，从而削弱主站的链接总量。既然作为网站排名关键因素之一的外链数量受到了影响，网站排名降低也是很自然的事情了。<br/><br/>当不能控制服务器且不支持自定义.htaccess或http.ini文件，或者需要根据动态的条件进行跳转，可以用动态程序实现301，linux主机一 般支持.htaccess，所以可以用<a href="website-301-redirect-method/" target="_blank">.htaccess文件</a>来进行301重定向，如果非linux主机空间不支持.htaccess文件，那么我们还可以通过php/asp/jsp代码来进行301重定向，不管 jsp asp php 程序原理都是一样的，即设置头部状态码和要跳转目标URL，发送头部就行了。<br/>PHP：<br/>在 index.php 的最顶部加入以下几行：</span><textarea name="code" class="php" rows="15" cols="100">
&lt;?php
header(&quot;HTTP/1.1 301 Moved Permanently&quot;);
header(&quot;Location: http://www.hecks.tk/&quot;);
exit();
?&gt;</textarea><br/><span style="font-family: 微软雅黑;">ASP、ASP.net：<br/>在 index.asp 或 default.asp 的最顶部加入以下几行：</span><textarea name="code" class="js" rows="15" cols="100">
&lt;%
Response.Status=&quot;301 Moved Permanently&quot;
Response.AddHeader &quot;Location&quot;,&quot;http://www.hecks.org.ru/&quot;
Response.End
%&gt; </textarea><br/><span style="font-family: 微软雅黑;">jsp：<br/>在 index.jsp 或 default.jsp 的最顶部加入以下几行：</span><textarea name="code" class="js" rows="15" cols="100">
&lt;%
response.setStatus(301);
response.setHeader(&quot;Location&quot;,&quot;http://www.hecks.tk/&quot;);
%&gt; </textarea><br/><span style="font-family: 微软雅黑;">多个域名绑一个站怎么做301：如jock.tk,jason.org.ru,www.jock.tk和www.hecks.org.ru都是绑在一个站，为了网址规范化都要跳转到www.hecks.org.ru这个主域名上，这时不能光写上面的代码，否则就成循环跳转了，要进行条件判断，即对主机头不是www.hecks.org.ru才转向，以ASP为例：</span><textarea name="code" class="js" rows="15" cols="100">
IF Request.Url.Host&lt;&gt;&quot;www.hecks.org.ru&quot; THEN
string newurl=&quot;http://www.hecks.org.ru&quot; &amp; Request.Url.PathAndQuery
Response.Status=&quot;301 Moved Permanently&quot;
Response.AddHeader &quot;Location&quot;, newurl
END IF</textarea><br/>Tags - <a href="https://www.heckjj.com/tags/%25E4%25B8%258D%25E6%2594%25AF%25E6%258C%2581/" rel="tag">不支持</a> , <a href="https://www.heckjj.com/tags/.htaccess/" rel="tag">.htaccess</a> , <a href="https://www.heckjj.com/tags/%25E9%259D%259Elinux%25E4%25B8%25BB%25E6%259C%25BA/" rel="tag">非linux主机</a> , <a href="https://www.heckjj.com/tags/%25E6%2580%258E%25E4%25B9%2588%25E5%2581%259A/" rel="tag">怎么做</a> , <a href="https://www.heckjj.com/tags/301/" rel="tag">301</a> , <a href="https://www.heckjj.com/tags/%25E9%2587%258D%25E5%25AE%259A%25E5%2590%2591/" rel="tag">重定向</a>
]]>
</description>
</item><item>
<link>https://www.heckjj.com/supportness-htaccess-host-301-redirect/#blogcomment</link>
<title><![CDATA[[评论] php asp asp.net jsp不支持.htaccess怎么做301重定向]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://www.heckjj.com/supportness-htaccess-host-301-redirect/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>