资讯中心

SEO工具

首页 >技术资讯 > SEO工具 >

网站SEO优化必备:常见程序301重定向的做法都有那些?

  下面简单说在网页当中如何设置301重定向!

  1asp程序:

  <%

    dim Url: Url=request.ServerVariables("HTTP_HOST")

    if Url="ywlcm.net" then

    Response.Status="301 Moved Permanently"

    Response.AddHeader "Location",""

    Response.End

    end if

    %>

  <%

    if request.ServerVariables("HTTP_HOST")""then

    Response.Status="301MovedPermanently"

    Response.AddHeader"Location",""

    Response.End

    endif

    %>

  2PHP程序:

  

    $hostdomain=$_SERVER['HTTP_HOST'];

    if ($hostdomain != '') {

    header("HTTP/1.1 301 Moved Permanently");

    header("location:");

网站SEO优化必备:常见程序301重定向的做法都有那些?

    exit();

    }

    ?>

  3伪静态301代码!~

  加在index.php中的

  

    $jump301=1;

    if(substr($_SERVER['SERVER_NAME'],0,4)!=''&&$jump301)

    {

    header('HTTP/1.1 301 Moved Permanently');

    header('Location:'.$_SERVER['SERVER_NAME']);

    exit();

    }

    4js跳转代码

  如有盆友看不懂的,可以给我留言哦,相互学习。

顶部