PHP/ASP/JSP/ASP.NET/CGI/ColdFusion的301重定向代碼

2010-08-28 10:56:13來源:西部e網作者:

301重定向不但可以在Apache服務器或者IIS中配置,也可以使用代碼的形式來做301重定向,而且方法很簡單,這里icech整理了一個各種語言編寫的301重定向代碼給大家,各取所需吧!

PHP 301 重定向代碼

301重定向也可以在php文件中通過加入php header來實現(xiàn),代碼如下:

    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header("Location:     exit();
    ?>

ASP 301 重定向代碼

    <%@ Language=VBScript %>
    <%
    Response.Status="301 Moved Permanently"
    Response.AddHeader "Location",
http://farlee.info
    %>

ASP.NET 301 重定向代碼

    <script language="c#" runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.Status = "301 Moved Permanently";
    Response.AddHeader("Location",http://farlee.info);
    }
    </script>

ColdFusion 301 重定向代碼

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

CGI Perl下的301轉向代碼

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

JSP下的301轉向代碼

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

贊助商鏈接: