seo需要优化哪些内容和方法(常见程序301重定向的做法都有那些)
seo需要优化哪些内容和方法(常见程序301重定向的做法都有那些)end ifResponse.Endif Url="ywlcm.net" thenResponse.Status="301 Moved Permanently"Response.Addheader "Location" "http://www.yswlcm.net"
下面简单说在网页当中如何设置 301重定向!
1 asp程序:
<%
dim Url: Url=request.ServerVariables("HTTP_HOST")
if Url="ywlcm.net" then
Response.Status="301 Moved Permanently"
Response.Addheader "Location" "http://www.yswlcm.net"
Response.End
end if
%>
<%
if request.ServerVariables("HTTP_HOST")<>"http://www.yswlcm.net" then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location" "http://www.yswlcm.net"
Response.End
end if
%>
2 PHP程序:
<?php
$hostdomain=$_SERVER['HTTP_HOST'];
if ($hostdomain != 'www.yswlcm.net') {
header("HTTP/1.1 301 Moved Permanently");
header("location:http://www.yswlcm.net");
exit();
}
?>
3 伪静态 301代码!~
加在 index.php中的
<? php 后面
$jump301=1;
if(substr($_SERVER['SERVER_NAME'] 0 4)!='www.'&&$jump301)
{
header('HTTP/1.1 301 Moved Permanently');
header('Location:http://www.'.$_SERVER['SERVER_NAME']);
exit();
}
4 js跳转代码
<script language=javascript>
if (document.domain !='www.yswlcm.net')
this.location = "http://www.yswlcm.net" this.location.pathname this.location.search;
</script>
如有盆友看不懂的,可以给我留言哦,相互学习。