How to redirect a URL fragment – hashtag in the URL

If you have address similar to http://host/#/blah, only ‘host’ is sent to the webserver – #/blah is only handled in the browser. This is called a fragment identifier.

You can get around it by adding javascript to the page(s) you want to redirect as follows, changing up the catch-all for specifics:

var redirectFragment = window.location.hash.replace(/^#/,”);
if ( ” !== redirectFragment ) {
window.location = ‘http://www.google.com’;
}

Advertisements