I've made a webpage that has the URL-form http://www.example.com/module/content It's a very dynamic webpage, actually it is a web app.

我做了一个网页有url表单http://www.example.com/module/content它是一个动态的网页,实际上它是一个web应用。

To make it as responsive as possible, I want to use AJAX instead of normal page requests. This is also enabling me to use JavaScript to add a layer to provide offline capabilities.

为了使它尽可能地具有响应性,我希望使用AJAX而不是普通的页面请求。这也使我能够使用JavaScript添加一个层来提供脱机功能。

My question is only: How should I make the URLs? Should they be http://www.example.com/module/content or http://www.example.com/#!/module/content?

我的问题是:我应该如何制作url ?应该是http://www.example.com/module/contentor http://www.example.com/#!/模块/内容?

Following is only my thoughts in both directions. You don't need to read it if you already have a clear thought about this.

以下只是我在两个方向上的想法。如果你已经有一个清晰的想法,你不需要读它。

I want to use the first version because I want to support the new HTML5 standard. It is easy to use, and the URLs look pretty. But more importantly is that it allows me to do this:

我想使用第一个版本,因为我想支持新的HTML5标准。它很容易使用,而且url看起来很漂亮。但更重要的是,它允许我这样做:

If the user requests a page, it will get a full HTML page back.

如果用户请求一个页面,它将返回一个完整的HTML页面。

If the user then clicks a link, it will insert only the contents into the container div via AJAX.

如果用户单击一个链接,它将仅通过AJAX将内容插入到容器div中。

This will enable users without JavaScript to use my website, since it does not REQUIRE the use to have JavaScript, it will simply use the plain old "click a link-request-get full html page back"-approach.

这将使没有JavaScript的用户能够使用我的网站,因为它不需要使用JavaScript,它只需要使用“单击链接请求-获取完整的html页面”方法。

While this is great, the problem is of course Internet Explorer. Only the last version of IE supports History API, and to get this working in older versions, one needs to use a hashtag. (50 % of my users will be using IE, so I need to support it...) So then I have to use /#!/ to get it working.

虽然这很好,但问题当然是Internet Explorer。只有IE的最后一个版本支持History API,要使其在旧版本中工作,需要使用hashtag。(50%的用户会使用IE,所以我需要支持它…)所以我必须使用/#!/让它工作。

If one uses both these URL-versions, the problem arises that if a IE user posts this link to a website, Google will send the server a _unescaped_string (or similar..) And it will index the page with the IE-version with the hashtag. And some pages will be without the hashtag.

如果一个用户使用两个url版本,那么问题就出现了:如果一个IE用户将这个链接发布到一个网站上,谷歌将会发送一个_unescaped_string(或类似的)服务器。它将使用带有标签的ie版本来索引页面。有些页面将没有标签。

And as we remember, a non-hashtag is better on many different things. So, can this search engine problem be circumvented? Is it possible to tell the GoogleBot that if it's reaching for the hashtag-version of the website, it should be redirected to the non-hashtag-version of the webpage? This way, one could get all the benefits of a non-hashtag URL and still support IE6-IE9.

正如我们所记得的,一个非hashtag在许多不同的东西上更好。那么,这个搜索引擎问题能被回避吗?有没有可能告诉GoogleBot,如果它要访问网站的hashtag-version,它应该被重定向到网页的非hashtag-version ?通过这种方式,可以获得非hashtag URL的所有好处,并且仍然支持IE6-IE9。

What do you think is the best approach? Maybe you have tried it in practice yourself? Thanks for your answer!

你认为最好的方法是什么?也许你自己也试过了?谢谢你的回答!

3 个解决方案

#1


9

If you want Google to index your Ajax content then you should use the #!key=value like this. That is what Google prefers for Ajax navigation.

如果您希望谷歌索引Ajax内容,那么您应该使用#!这样的键=值。这就是谷歌更喜欢的Ajax导航。

If you really prefer the pretty HTML5 url without #! then, yes, you can support both without indexing problems! Just add:

如果你真的喜欢没有#的HTML5 url !然后,是的,您可以同时支持这两种方法,而不存在索引问题!添加:

<link rel="canonical" href="preferredurl" />

to the <head> section of each page (for the initial load), so to help Google know which version of the url you would prefer them index. Read more about canonical urls here.

到每个页面的部分(对于初始加载),以便帮助谷歌知道您希望它们索引哪个版本的url。请阅读更多有关规范url的内容。

更多相关文章

  1. 当页面上有多个按钮时,按钮样式在页面加载上有厚的边框
  2. 调用另一个html页面后,选择列表值不会保持不变
  3. JavaScript实际应用:父子页面交互
  4. 根据用户时区显示当地时间 php+javascript
  5. Google Maps API v3:如何设置缩放级别和地图中心到用户提交的位置
  6. 执行javascript作为coldfusion页面加载
  7. 如何在页面上获得带有javascript的特定单词的链接
  8. 我可以在JavaScript中从不同的页面传递参数吗?
  9. Ajax的实用技术——用户的注意力从页面的其他区域到转移选择的图

随机推荐

  1. Android直播开源项目
  2. Android(安卓)HAL的被调用流程
  3. Android属性动画上手实现各种动画效果,自
  4. 2013年01月06日
  5. android Activity类的使用
  6. Intellij IDEA 导入 Android(安卓)SDK
  7. Android(安卓)App接入微信开放平台注意事
  8. Android(安卓)ART模式简介
  9. Android中moveTo、lineTo、quadTo、cubic
  10. [置顶] Android事件总线还能怎么玩?