Adios表示再见–浏览器301以所有语言重定向

    技术2022-07-11  139

    Browser redirects, especially 301 "permanent" redirects, are essential to all good web applications. Regardless of language, browser redirects can:

    浏览器重定向,尤其是301个“永久”重定向,对于所有良好的Web应用程序都是必不可少的。 无论使用哪种语言,浏览器重定向都可以:

    provide safe URL forwarding to gather GET and POST variables and process them without risking data and processing integrity by a browser refresh

    提供安全的URL转发以收集GET和POST变量并处理它们,而不会因浏览器刷新而冒着数据和处理完整性风险的危险 send users and search engine bots to the new location of a page or entire website

    将用户和搜索引擎漫游器发送到页面或整个网站的新位置 maintain search engine rank and avoid 404 errors

    维持搜索引擎排名并避免404错误

    Here's the list of browser redirects using various languages:

    以下是使用各种语言进行的浏览器重定向的列表:

    .htaccess (.htaccess)

    redirect 301 / http://www.davidwalsh.name/

    ASP (ASP)

    Response.Status="301 Moved Permanently"; Response.AddHeader("Location","http://www.davidwalsh.name/");

    ASP.NET (ASP.NET)

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

    ColdFusion (ColdFusion)

    <CFHEADER statuscode="301" statustext="Moved Permanently"> <CFHEADERname="Location" value="http://www.davidwalsh.name">

    Javascript(不是301) (Javascript (NOT a 301) )

    //window.location.href = 'http://www.davidwalsh.name/';

    Java JSP (Java JSP)

    response.setStatus(301); response.setHeader("Location", "http://www.davidwalsh.name/"); response.setHeader("Connection", "close");

    元标记(不是301) (Meta tag (NOT a 301))

    <meta http-equiv="refresh" content="0;url=http://www.davidwalsh.name/" />

    Perl (Perl)

    use strict; print "Status: 301 Moved Permanantlyn"; print "Location: http://www.davidwalsh.name"; exit;

    PHP (PHP)

    header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.davidwalsh.name');

    Ruby On Rails (Ruby On Rails)

    def old_action headers["Status"] = "301 Moved Permanently" redirect_to "http://www.davidwalsh.name/" end

    Do you have any more redirect scripts? If so, post them below!

    您还有其他重定向脚本吗? 如果是这样,请将其张贴在下面!

    翻译自: https://davidwalsh.name/browser-301-redirects

    相关资源:jdk-8u281-windows-x64.exe
    Processed: 0.041, SQL: 9