[Tutorial] How to Make Your Own Mass URL Shortener

tacopalypse

Senior Member
Joined
Nov 30, 2009
Messages
935
Reaction score
2,533
first, head over to your favorite domain registrar. (godaddy, namecheap, enom, etc)

type in 2 random numbers and 1 random letter to get a 3-letter domain name. the cheapest 2-letter TLDs are .us and .me at around $8, and 90% of them aren't taken yet.
(or you can just get the .info you're broke and don't mind the 2 extra letters)
example: 4m5.us (uber-short!)

attach it to any ol' hosting. free hosting works just fine, as all we'll be doing is bouncing redirects off of it.

open up notepad and create this php file:
index.php
PHP:
<?php 

$a = array( 

0 => 'http://www.google.com',  
1 => 'http://www.yahoo.com',  
2 => 'http://www.ask.com',  
3 => 'http://www.meatspin.com',  
4 => 'http://www.blackhatworld.com',  

); 
  
header('Location: ' . $a[$_SERVER['QUERY_STRING']]);  

?>

put the index.php at the root of your domain, and make sure to delete any index.html or index.htm files that may already be there.
then you can link your shortened urls like this: (where the number at the end is the index of the url you want to redirect to)
Code:
4m5.us?3


enjoy :D
 
Last edited:
Clever stuff many thanks tacopalypse.
Could this be then used as a public service like the others with ads on the site?
or would that "overheat" your hosting account?
 
if you wanted to make it public and allow your visitors to input their own links, then you'd have to make an interface for it and probably store all your links into a mysql database or something, which gets a little more complicated than the stuff here.

on the other hand, you could just have your visitors send you the links manually and then place them into the source code yourself, but that could get tedious :P

simple redirects like this wouldn't generate hardly any server load unless you were sending like hundreds of thousands of clicks through it or something
 
That looks really useful, but would people click on them given they wouldn't have heard of the url shortern before?
 
the link looks sketchy as all hell xD

but imo, bitly links and any url shortener links look pretty sketchy to begin with.
the intention that you're hiding the destination url is pretty obvious either way.

best way to make your links 'friendly looking' is to buy a dedicated domain for it and bounce redirects off of that, but that can get expensive
 
To save time and find a Bunch of 3 character possible domains I went to AV*XHome and searched for a random number/password generator.

Found Password Generator pro,installed and
set it for 3 numbers/letters combinations and for 500 results.
ran it and posted the results at GoDaddy and found some nice ones to select from.
Sure beats typing in by hand :)

JB
 
What do you think of using subdomains for affiliate links? I have been doing that for a while and it seems to be ok.What would happen if you got a ton of traffic to go through a subdomain to a affiliate site?
 
Nice mate, really nice. I created a URL shortener app the other day using yourls. Really easy even for a newby! Wish I could post the URL but can't!lol
 
if you wanted to make it public and allow your visitors to input their own links, then you'd have to make an interface for it and probably store all your links into a mysql database or something, which gets a little more complicated than the stuff here.

There is a way of doing this without MySQL if you want something quick and dirty....if I get 10 minutes tonight I will show you how :)
 
Fatboy,

I have a free short domain if you want to work with me to do a BHW shortner?

nice and simple.

my php sucks though
 
Back
Top