Sysadmin

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s