我想将纯HTML网页重定向到新URL,但是我尝试过的所有内容(元刷新,Javascript重定向)都会导致旧URL出现在新页面的地址栏中,即使在清除浏览器缓存后也是如此。 .htaccess 重定向有时有效,但由于旧页面已经是来自另一个域的重定向目标这一事实而变得复杂。我无权访问主机帐户。
任何人都可以建议一种方法使新URL始终出现在新页面的地址栏上吗?多谢。
使用元刷新标记应该可以正常工作。
<meta http-equiv="refresh" content="0; url=http://example.com/" />
注意:将其放在头部部分。
您可能还想执行 javascript 重定向,因为 W3C 不建议使用元标记方法,尽管它可能不适用于所有移动浏览器。连同后备文本链接,这将使您的页面类似于:
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1; 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>
非常感谢上一个答案的答案:从 HTML 页面重定向