如何最好地重定向一个网页,而不使用JavaScript? [英] How best to redirect a webpage without using Javascript?

查看:72
本文介绍了如何最好地重定向一个网页,而不使用JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



目前我有以下内容:

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

但我已经读过,这不像一些搜索引擎那么明智。如何做到这一点,并保持搜索引擎快乐?您可以在服务器端重定向301 HTTP状态码。这是做好SEO的最佳方式。这个例子是用C#编写的,但是每个plattform都有自己的方法来为响应添加头文件:

  Response.Clear(); 
Response.Status =301永久移动;
Response.AddHeader(Location,/ newfolder / newfilelocation);

使用301状态码的原因是搜索引擎将新页面编入索引,因为它是永久移动而不是暂时移动的302.


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?

解决方案

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".

这篇关于如何最好地重定向一个网页,而不使用JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆