是否可以设置一个基本的 HTML 页面以在加载时重定向到另一个页面?
原文由 chobo 发布,翻译遵循 CC BY-SA 4.0 许可协议
我会同时使用 meta 和 _JavaScript 代码_,并且会有一个链接以防万一。
<!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 状态代码。这很容易通过使用 Apache 的 .htaccess
文件或使用 WordPress 的众多插件来实现。我相信还有适用于所有主要内容管理系统的插件。此外,如果您的服务器上安装了 cPanel,则它可以非常简单地配置 301 重定向。
原文由 Billy Moon 发布,翻译遵循 CC BY-SA 3.0 许可协议
2 回答1.4k 阅读✓ 已解决
2 回答846 阅读✓ 已解决
1 回答1.1k 阅读✓ 已解决
1 回答849 阅读✓ 已解决
2 回答766 阅读
1 回答738 阅读✓ 已解决
2 回答1.1k 阅读
尝试使用:
注意:将其放在
<head>
部分。此外,对于旧版浏览器,如果您添加快速链接以防它无法正确刷新:
<p><a href="http://example.com/">Redirect</a></p>
将显示为
重定向
这仍然可以让您通过额外的点击到达您要去的地方。