如何在不使用 JavaScript 的情况下最好地重定向网页?

发布于 2024-07-22 05:32:10 字数 285 浏览 4 评论 0原文

我的默认页面中有一些脚本,可以根据浏览器的语言将用户重定向到我网站的特定语言版本。 我想添加一些内容来重定向那些未启用 Javascript 的用户。

目前我有以下内容:

<noscript>
  <META HTTP-EQUIV=REFRESH CONTENT="1; URL=en/index.htm">.
</noscript>

但我读过这不太明智,因为一些搜索引擎对此不以为然。 我该如何做到这一点并让搜索引擎满意?

I have some script in my default page that redirects users to language specific versions of my website depending on the language of the browser. I want to add something that redirects those users who do NOT have Javascript enabled.

Currently I have the following :

<noscript>
  <META HTTP-EQUIV=REFRESH CONTENT="1; URL=en/index.htm">.
</noscript>

But I've read this is not too wise as some search engines frown upon it. How do I do this and keep search engines happy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

再见回来 2024-07-29 05:32:10

您应该使用 .htaccess 文件从标头中检测浏览器的语言(使用正则表达式),然后以这种方式重定向它们。 这样做与客户端配置完全无关,搜索引擎将正确处理它。 有大量关于具体如何实现这一目标的信息。

You should use a .htaccess file to detect the browser's language from the headers (using a regular expression) and then redirect them that way. Doing that is completely agnostic of the client-side configuration and search engines will handle it properly. There is a ton of information out there on specifically how to accomplish this.

蓝海似她心 2024-07-29 05:32:10

可以使用服务器端语言来完成,添加以下 http 标头

Location: /en/index

将用户重定向到 http:// www.example.com/en/index

It could be done with a server side language by adding the following http header

Location: /en/index

will redirect the user to http://www.example.com/en/index

沙沙粒小 2024-07-29 05:32:10

您也可以在服务器端使用 301 HTTP 状态代码进行重定向。 这是实现良好 SEO 的最佳方法。 该示例是用 C# 编写的,但每个平台都有自己的方法来向响应添加标头:

Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "/newfolder/newfilelocation");

使用 301 状态代码的原因是搜索引擎索引新页面,因为它是“永久移动”而不是“已永久移动”的 302。暂时搬家了”。

You can redirect at server side with 301 HTTP status code too. This is the best way to do it for good SEO. The example is in C# but every plattform has his own method to add headers to the response:

Response.Clear();
Response.Status = "301 Moved Permanently";
Response.AddHeader("Location", "/newfolder/newfilelocation");

The reason to use the 301 status code is that the search engine indexes the new page because it was "Moved permanently" instead of the 302 that was "Moved temporarily".

你怎么这么可爱啊 2024-07-29 05:32:10

为什么不通过使用 302 HTTP 状态代码进行响应来在服务器端进行重定向。 我不知道你的服务器上有什么,但所有框架都支持它。

Why don't you redirect on the server side, by responding with a 302 HTTP status code. I don't know what you have on the server, but all frameworks support it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文