Question

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.

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.

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?

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:

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

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

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.

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.

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.

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.

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

Was it helpful?

Solution

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.

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

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

OTHER TIPS

In that case the solution is very easy. You use the first URL scheme, and you don't use AJAX enhancements for older IE browsers.

If your precious users don't want to upgrade, it's their problem, but they can't complain about not having these kewl effects and dynamics.

You can throw a "Your browser is severely outdated!" notice for legacy browsers as well.

I would not use /#!/ in the url. First make sure the page works normally, with full page requests (that should be easy). Once that works, you can check for the window.history object and if that is present add AJAX. The AJAX calls can go to the same url and the main difference is the server side handling. The check is simple, if the HTTP_X_REQUESTED_WITH is set then the request is an AJAX request and if it is not set then you're dealing with a standard request.

You don't need to worry about duplicate content, because GoogleBot does not set the HTTP_X_REQUESTED_WITH request header.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top