6 March 2007

Short / Tiny URL ... just do it yourself...

There are so many URL redirection services out there… and they all do a good job in some form or the other… but can you always depend on them being up … or worse yet redirecting your users elsewhere … not for me …

Let me first state I am not in the business of creating a service of tiny urls, but I put together a few php files that i think anyone could use on their own servers…

da demo

short.nuff-respec.com

da players (some)

An example … url123 is not in service as i write this … and the main one (tinyurl) that i have used really give nonsense urls … example: http://tinyurl.com/3ajqom … where does it go?

da difference

Basically the main difference is that it lives on your server… and you specify your own urls … and maintain your own database… now which one makes more sense to you?
http://short.nuff-respec.com/maps/hsquare
http://tinyurl.com/2kscmk

So my example is not as tiny (they have a smaller url to start with)... but it sure beats the original google address and is human readable …

da usage

url : the url you want to make tiny
domain alias : basically a short name if the domain
url alias : your own alias

Even though the aliases are optional … it’s worth putting them in … random strings will be generated and will not be as user friendly… An added touch is that once a domain alias has been set … all subsequent calls to that domain will automatically be tagged… i have already mapped “maps.google.com —> maps” and “www.google.com —> google” so i don’t have to fill in those domains again… go ahead try

da .htaccess file

Basically if file doesn’t exist .. then run “index.php”

.
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^(.+) - [PT,L]
 RewriteRule ^(.*) index.php
</IfModule>

da source

If demand is there … i will write detail explanation of the source, but it is well commented and a basic novice should find it relatively easy to install on your own …

note … there was an error on line 220 in index.php … should be:

.
$short_url = $short_host . '/' . code(4);

shorturl.zip


good luck … how about some puppy images to leave you with !!


 

comment

what they saidwho said it

Hi :) Some great code there.. well done and tidy… we have used it for some of our site links http://tiny.wackyb.net thanks!

2007-04-25
Andy (WackyB)

I’m implementing it as we speak. Great code, works wonderfully! I’ll be continuing to make use of this long into the future.
tiny.fuzzy-dice.net

Thanks!

2008-06-04
KickMeElmo


note: you can only submit after you hit preview


nuff-respec is a weblog written by daniel bulli a senior web programmer in boston, ma.
more >

contact | resume | profile | twitter

recently :::

diversions :::

45+ Amazing Insect Shots in Photography
Insects are one of the most fascinating creatures on earth. There are more than 800, 000 species of insects in the world.
Grayscale color | Stroep Blog
This is how I create a grayscale color in actionscript 3.
Google Flash API
This is great ... google has made this easy ... stay tuned to see what i am working on ...
25 Free Mac Apps That Will Boost Your Productivity
There are many applications that can help you work faster and efficiently. Though, not many applications come cheap.
you still want more »