url-shortener

Java: How to easily check if a URL was already shortened?

与世无争的帅哥 提交于 2019-12-05 07:47:30
If I have a general url (not restricted to twitter or google) like this: http://t.co/y4o14bI is there an easy way to check if this url is shortened? In the above case, I as a human can of course see that it was shortend, but is there an automatic and elegant way? You could do a request to the URL, look if you get redirected and if so, assume it's a shortening service. For this you'd have to read the HTTP status codes. On the other hand, you could whitelist some URL shortening services (t.co, bit.ly, and so on) and assume all links to those domains are shortened. Drawback of the first method is

How to obscure the id in a url (ruby on rails) [duplicate]

主宰稳场 提交于 2019-12-04 19:10:58
This question already has answers here : How do I obfuscate the ids of my records in rails? (5 answers) Closed 4 years ago . I have a web app made with Ruby On Rails. For now when I want to display an object I have to access the following page: http://mywebapp.com/object/1234 with 1234 the id of the object. I would like to encode that object id and have the following result: http://mywebapp.com/object/5k (it is just an example). How can it be done? Many thanks, Martin bender All these converting methods are reversible, so IMHO if your object has some name or title or whatever, then the best

How to un-shorten (resolve) a url using python, when final url is https?

烂漫一生 提交于 2019-12-04 18:15:36
I am looking to unshorten (resolve) a url in python, when the final urls are https. I have seen the question: How can I un-shorten a URL using python? (as well as similar others) , however as noted in the comment to the accepted answer, this solution only works when the urls is not redirected to https. For reference, the code in that question (which works fine when redirecting to http urls) is: # This is for Py2k. For Py3k, use http.client and urllib.parse instead, and # use // instead of / for the division import httplib import urlparse def unshorten_url(url): parsed = urlparse.urlparse(url)

URL shortener: best encoding method?

假如想象 提交于 2019-12-03 09:19:38
问题 I'm creating a link shortening service and I'm using base64 encoding/decoding of an incremented ID field to create my urls. A url with the ID "6" would be: http://mysite.com/Ng== I need to also allow users to create a custom url name, like http://mysite.com/music Here's my (possibly faulty) approach so far. Help in fixing it would be appreciated. When someone creates a new link: I get the largest link ID from the database (it's not auto incremented) Increment the ID by 1 Generate a short URL

How do I get the final, redirected, canonical URL of a website using PHP?

♀尐吖头ヾ 提交于 2019-12-03 05:35:35
In the days of link shorteners and Ajax, there can be many links that ultimately point to the same content. I was wondering what the best way is to get the final, best link for a web site in PHP, hopefully with a library. I was unable to find anything on Google or GitHub. I have seen this example code, but it doesn't handle things like a rel="canonical" meta tags or default ssl ports: http://w-shadow.com/blog/2008/07/05/how-to-get-redirect-url-in-php/ Facebook seems to handle this pretty well, you can see how they follow 301's and rel="canonical", etc. To see examples of the way Facebook

How does URL shorteners process the code after the domain?

社会主义新天地 提交于 2019-12-03 01:28:23
问题 I'm trying to create a URL shortener service. Most URL shortener services have use a code following the domain. For example, http://bit.ly/duSk8wK, duSk8wK would be the code. What code is needed in .htaccess file to make the server read the path part 'duSk8wK' and query in database, instead of going to the folder name /duSk8wK? 回答1: In your Htaccess, you could make a rewriterule like this: RewriteRule ^([^/.]*)$ redirect.php/?code=$1 [L] Then in your redirect.php , you could simply get the

How does URL shorteners process the code after the domain?

夙愿已清 提交于 2019-12-02 15:14:14
I'm trying to create a URL shortener service. Most URL shortener services have use a code following the domain. For example, http://bit.ly/duSk8wK , duSk8wK would be the code. What code is needed in .htaccess file to make the server read the path part 'duSk8wK' and query in database, instead of going to the folder name /duSk8wK? Wesley Peeters In your Htaccess, you could make a rewriterule like this: RewriteRule ^([^/.]*)$ redirect.php/?code=$1 [L] Then in your redirect.php , you could simply get the code by using $_GET["code"] . 来源: https://stackoverflow.com/questions/34855381/how-does-url

how to shorten the url in a mathematical approach

扶醉桌前 提交于 2019-12-01 22:20:57
问题 I am looking into the possibility of shortening / encrypting a url which will be from 150 to 250 characters in length to maximum 12 characters using an algorithm. Initially I am doubting it's possible but I wanted to leverage the great minds of StackOverflow :) the algorithm should be one that can be written in classic asp, sql, c#, vb, or foxpro or other language. Is that even possible without a database centric approach? I was reading here that AES in CFB mode, will do a stream cipher and

how to shorten the url in a mathematical approach

夙愿已清 提交于 2019-12-01 21:09:55
I am looking into the possibility of shortening / encrypting a url which will be from 150 to 250 characters in length to maximum 12 characters using an algorithm. Initially I am doubting it's possible but I wanted to leverage the great minds of StackOverflow :) the algorithm should be one that can be written in classic asp, sql, c#, vb, or foxpro or other language. Is that even possible without a database centric approach? I was reading here that AES in CFB mode, will do a stream cipher and the output length will be the same as the input length. Is there any way to shorten it even more? The

Base10 to base64 url shortening

大兔子大兔子 提交于 2019-11-30 21:16:44
I'm coding an url shortener function for a project in which I'm learning php, here is the code (btw I suppose that global here is not a good thing to do :P): $alphabet = array(1 => "a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z", "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z", "0","1","2","3","4","5","6","7","8","9","_","-"); function shorten($id){ global $alphabet; $shortenedId = ""; while($id>0){ $remainder = $id % 64; $id = $id / 64; $shortenedId = $alphabet[$remainder].