rabhw
rabhw

Reputation: 81

Adding hashbang to URL if not already present

Problem

I've got my site up and running using #! URLs and PathJS working nicely. It works fine when someone is linked to a URL that already contains the proper URL structure that contains the hashbang.

The only issue I'm having is when a user visits a page without the hashbang in the URL, it needs to append the hashbang then either reload the page, or hopefully trigger PathJS to detect the proper URL structure and do what I've told it to.

Example

Visiting http://twitter.com/google will intercept that URL, change it to http://twitter.com/#!/google and then load in the appropriate content.

Upvotes: 1

Views: 353

Answers (1)

Ateş Göral
Ateş Göral

Reputation: 140112

You can define a root route with:

Path.root("#!/hello");

When a user comes to the page without any hashes, PathJS will default to the root route.

Upvotes: 1

Related Questions