Question

I use this method:

Hashbang URLs using Ember.js

And now i have website with hashbangs. But people come also to old URLs with only hash, but without hashbang.

So how to change URL from only hash to hashbang if someone visits the old style url?

Was it helpful?

Solution

I dont think you need to tweak ember for that. Simple solution is before ember application loads you can run the following code.

    var url = window.location.toString();

    if(url.split('#!').length==1) {
      if(url.split('#').length==2) {
        window.location = url.split('#')[0]+'#!' + url.split('#')[1];
      }
    }

Basically what it does is rewrites the url to #!.

UPDATE: Else one more way is write above code in Ember Initializers.

Here is the jsbin http://emberjs.jsbin.com/aLiretO/1#post

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