user1659302
user1659302

Reputation: 91

shortening of url in address bar

I am new to html. Is it possible to have Short URL for apps? for example:- instead of long url "www.abc.com\x\y\z\a" can we have "www.abc.com\r" in the user 's address bar. can we emulate this using javascript?

Upvotes: 4

Views: 417

Answers (3)

Jasper de Vries
Jasper de Vries

Reputation: 20158

Yes, you could by creating a document at location /rand adding a Javascript to that document which simply does:

document.location.href = "/x/y/z/a";

But, for many reasons you shouldn't.

  1. It's not a redirect (you can go back in you browser, so you are basically breaking your history)
  2. You rely on Javascript
  3. It will have a negative effect on SEO
  4. It's slower
  5. ...

You really should try to handle this at the server side of you application.

Upvotes: 1

Dipak
Dipak

Reputation: 12190

You are looking for url rewriting

read on URL Rewriting in ASP.NET

URL Rewriting for Beginners

Upvotes: 1

CloudyMarble
CloudyMarble

Reputation: 37566

This is done using Database which gets the long URL to the Short one, so its noting you can do on Clientside only using Javascript.

Upvotes: 0

Related Questions