Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an URL shortener pass parameters?

Tags:

redirect

url

I use bit.ly to shorten my urls. My problem - paramters are not passed. Let me explain I use http://bit.ly/MYiPhoneApps which redirects (let's say) to http://iphone.pp-p.net/default.aspx Now when I try http://bit.ly/MYiPhoneApps?param=xx this param is not added to the resulting url. I know I could create an extra "short url" including a paramter - so http://bit.ly/WithParam would result in http://www.mysite.com/somepath/apage.aspx?Par1=yy and so forth.

But what I want is to have a short URL directing to a page - and then I want to add a parameter to this shortened url - which shoul (of course) land at my page.

Is this a shortcome of bit.ly (and others are maybe able to do it) - or does "parameter forwarding" not work with 301 redirections?

Manfred

like image 397
ManniAT Avatar asked Apr 03 '10 21:04

ManniAT


People also ask

What does shortening a URL do?

URL shortening is the translation of a long Uniform Resource Locator (URL) into an abbreviated alternative that redirects to the longer URL. The original URL shortening service was TinyURL, which was launched in 2002 by Kevin Gilbertson to make links on his unicyclist site easier to share.

How do you give parameters in URL?

Any word after the question mark (?) in a URL is considered to be a parameter which can hold values. The value for the corresponding parameter is given after the symbol "equals" (=). Multiple parameters can be passed through the URL by separating them with multiple "&".

Is it safe to shorten a URL?

The security risk with a shortened URL is you cannot tell where you are going when you click the link, you have to trust the sender. As a result, some organizations teach their employees not to trust shortened URLs, or simply block them at their network gateway.

Can you customize a shortened URL?

You can create your own custom short URLs with Bitly tools or using Buffer, Hootsuite, or other tools that work with Bitly. Use your custom URL for links to any of your content, name, brand, photos, or blog posts.


2 Answers

There's no technical reason why it couldn't be done. The service would simply have to look at what parameters it is being sent, and then rewrite the target URL accordingly.

The problem is that it's not necessarily well defined how to do that.

Suppose you have the url http://example.com/default.aspx?foo=bar, and it has the short url http://foo.com/ABCD. What should happen if you try to access http://foo.com/ABCD?foo=baz? Should it replace the value, so you get foo=baz? Should it append it to make foo=bar&foo=baz? If we include both, which order should they be in?

The system cannot know which parameters are safe to override and which are not, because sometimes, you DO want both of them in the URL, and it may matter what order things are added in.

You could argue "Well, just don't allow this for URLs where parameters are already present", but there's also the issue that it's going to complicate the process a lot more. Without this, you just lookup a key in a database and send a redirect header. Now, you need to also analyze the URL to check for parameters, and append part of the URL you were called by. That requires more system resources per redirect, which may become a big problem if your service is used very frequently - you'll need more server power to handle the same amount of redirects. I don't think that tradeoff is considered to be "worth it".

like image 170
Michael Madsen Avatar answered Oct 04 '22 11:10

Michael Madsen


As mentioned in comments by rinogo and Jurgen

In Clickmeter

Destination URL : www.yoursite.com?myparam1={id1}&myparam2={id2} 
Tracking link   : www.go.clickmeter.com/38w2?id1=123&id2=abc 
After click     : www.yoursite.com?myparam1=123&myparam2=abc

In TinyUrl

Destination URL     : http://x.com?a=1
Shorten URL         : https://tiny url.com/y6gh7ovk
Shorten URL + param : https://tiny url.com/y6gh7ovk?a=2
Resultant URL       : http://x.com/?a=1&a=2

Added space to post tinyurl

like image 31
Smart Manoj Avatar answered Oct 04 '22 11:10

Smart Manoj