X
WվO| | DΈD| | Fk| ϵy| ԇJC| Wjg| ܛ| XP| ČWƷ
 
Wվ_l| W| ϵy| DD| ԇJC| | | Ӳg| Fk| Wjg| ЦԒl
λã X-> -> Wjg-> Wj-> 301ض򷽷ȫ(HTML/ASP/ASPX/CGI/PHP/JSP)

301ض򷽷ȫ(HTML/ASP/ASPX/CGI/PHP/JSP)
ߣվ Դվ rg2010-8-28
P
  • 301ض302ضą^e
  • P:

        301ضҲ301D301DWվDzɺҕᘌSE棩̎Wվصĕr@ҪWվQĬJҪDSEOǶȁf҂hʹ301ضJSDMETA REFRESH302D@ЩSEđP

    ʲô301ض

    301ضǮÑWվlg[ՈrصHTTP^Ϣ (header)еĠBaһNʾWDƵһַҊĠBa߀200ʾһ404WҲ302rDȵ

    ʲôҪ301D

    WַD򷽷Ҫ301D302DJavaScriptDPHP/ASP/CGIDMETA REFRESHWMETAˢµ302DܕURLҎ}dzõַȻf]eö挦@ЩɵD򶼺αðU

     

    (һ)ʹõǪ, ڷ301ض

    1. windows IIS O
    IISϢ -- xWվ -- -- Ŀ -- xضURLݔҪDĿURLxYԴض
    ؈D:

    2. linuxt޸Apacheļ

    Apache301Da½.htaccessļݔЃݣҪ_mod_rewrite

    1)WWWD򵽎WWWOptions +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^lesishu.cn [NC]
    RewriteRule ^(.*)$ /$1 [L,R=301]

    2)ضOptions +FollowSymLinks
    RewriteEngine on
    RewriteRule ^(.*)$ /$1 [L,R=301]

    3)ʹtM301DFoBOptions +FollowSymLinks
    RewriteEngine on
    RewriteRule ^news-(.+)\.html$ news.php?id=$1news.php?id=123@ӵĵַDnews-123.html

    4)Apachevhosts.conf301D錍FURLҎSEOͨWWWD򵽎WWWvhosts.confÞ飺<VirtualHost *:80>
    ServerName 2006¹ www.xvvhh.com
    DocumentRoot /home/lesishu
    </VirtualHost><VirtualHost *:80>
    ServerName lesishu.cn
    RedirectMatch permanent ^/(.*) /$1
    </VirtualHost>

     

     

     

    ()ʹõ̓MC, tͨ^aʽ팍F301ض


    1)HTMLoBʹJavaScript301ضa

    <script language=javascript>
    if (document.domain =='yourolddomain')
        this.location = "//yourdomain" + this.location.pathname + this.location.search;
    </script>

     


    2)ASPµ301ض

    <%@ Language=VBScript %>

    <%

    Response.Status="301 Moved Permanently"

    Response.AddHeader "Location","2006¹ "

    %>

     


    3)PHPôaF301ضķ


    {?php

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

    header("Location:/");

    exit();

    ?}

     

     

    4)CGI Perlµ301ضa

    $q = new CGI;
    print $q->redirect("2006¹ ");

     


    5)JSPµ301Da

    <%
    response.setStatus(301);
    response.setHeader( "Location", "2006¹ " );
    response.setHeader( "Connection", "close" );
    %>

     

    6) ASP.Netµ301Da

    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location","2006¹ ");
    }
    </script>

     

    7)ColdFusion 301 ضa

    <.cfheader statuscode="301" statustext="Moved permanently">
    <.cfheader name="Location" value="2006¹ ">


    [T:tonny]

    P
  • 301ض302ضą^e
  • P:
    վ]

    CPI~:

    Wj
    ֪R
    }
    Wjȫ
    MWg
    WjA
    Wj

    X̳x
    Windows ʹÿļ...
    WWӹ톖}ȫλ...
    ϾWٶԭcQk
    Wʮ󽛵䑪ü(5~1...
    WWӹ톖}ȫλ...
    ϾWٶԭQ
    ADSLٶ
    301ض򷽷ȫ(HTML/...
    2006¹
    Wʮ󽛵䑪ü(10~...