从 HTML 页面重定向

问题描述

我会同时使用metaJavaScript 代码,并且会有一个链接以防万一。

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="0; url=http://example.com">
        <script type="text/javascript">
            window.location.href = "http://example.com"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        <!-- Note: don't tell people to `click` the link, just tell them that it is a link. -->
        If you are not redirected automatically, follow this <a href='http://example.com'>link to example</a>.
    </body>
</html>

为了完整起见,我认为如果可能的话,最好的方法是使用服务器重定向,因此发送301状态代码。这很容易通过.htaccess使用Apache的文件或通过使用WordPress的众多插件来实现。我相信所有主要的内容管理系统也都有插件。此外,如果您在服务器上安装了 301 重定向,cPanel 的配置非常简单。

尝试使用:

<meta http-equiv="refresh" content="0; url=http://example.com/" />

注意:将其放在头部。

此外,对于较旧的浏览器,如果您添加快速链接以防无法正确刷新:

Redirect

将显示为

重定向

这仍然可以让您通过额外的点击到达您要去的地方。

解决方法

是否可以设置一个基本的 HTML 页面以在加载时重定向到另一个页面?

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...