我有一个托管在商业提供商上的站点,所有站点都是在/portal 文件夹中开发的。
直到今天,我都使用框架集重定向网站:
<html>
<head>
<title>Titulo</title>
<meta name="google-site-verification" content="xxx" />
<meta http-equiv="Content-Language" content="pt-br">
<meta name="description" content="xxxx">
</head>
<FRAMESET>
<FRAME SRC="http://www.test.com.br/portal" NORESIZE>
<body></body>
</FRAMESET>
</html>
现在,主机提供商建议我使用:
<script>window.location='http://www.test.com.br/portal';</script>
这比框架集方法更快还是更好? Google 或其他搜索引擎是否会继续搜索该内容?
最佳答案
您可以通过不同的方式重定向到另一个页面。如果您使用的是服务器端语言,例如 php,您可以使用这个(在发送 header 之前):
header("Location: http://www.test.com.br/portal");
使用 HTML 你可以这样做:
<meta http-equiv="refresh" content="0;url=http://www.test.com.br/portal">
使用 Javascript 你可以这样做:
<script>window.location='http://www.test.com.br/portal';</script>
在我看来,最好的方法是第一种,因为您还可以指定重定向的类型(永久或临时),从 SEO 的角度来看,这种方法更好。如果您选择第一种解决方案,Google 和其他搜索引擎将能够轻松抓取您的网页。
关于html - 内部重定向站点的最佳解决方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8026847/