是否可以设置一个基本的HTML页面以在加载时重定向到另一个页面?
当前回答
我还将添加一个规范链接来帮助您的SEO人员:
<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish"/>
其他回答
尝试使用:
<meta http-equiv="refresh" content="0; url=http://example.com/" />
注意:将其放在<head>部分。
此外,对于较旧的浏览器,如果您添加了一个快速链接,以防无法正确刷新:
<p><a href=“http://example.com/“>重定向</a></p>
将显示为
重新使用
这仍然允许您通过额外的点击到达您要去的地方。
我将同时使用元代码和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的众多插件轻松实现。我确信所有主要的内容管理系统都有插件。此外,如果您的服务器上安装了301重定向,cPanel可以非常轻松地配置301重定向。
Razor引擎延迟5秒:
<meta http-equiv="Refresh"
content="5; url=@Url.Action("Search", "Home", new { id = @Model.UniqueKey }))">
JavaScript
<script type="text/javascript">
window.location.href = "http://example.com";
</script>
Meta标记
<meta http-equiv="refresh" content="0;url=http://example.com">
适用于所有类型页面的简单方法是在头部添加一个元标记:
<html>
<head>
...
<meta HTTP-EQUIV="REFRESH" content="seconds; url=your.full.url/path/filename">
...
</head>
<body>
Don't put much content, just some text and an anchor.
Actually, you will be redirected in N seconds (as specified in content attribute).
That's all.
...
</body>
</html>