Make your own URL Shortner Site in 3 minutes

G-S-T

Elite Member
Joined
Jan 20, 2011
Messages
1,762
Reaction score
9,092
Here is another freebie for you.

If your tired of getting your URL's disabled by the major shortners, overcome the problem by making your own.

You can have it up in 3 minutes.

The index page is just a simple no frills page with a form, see below.
ta5Yy


Installation:

1.Create a Database
2.Unpack files
3.Edit /includes/conf.php with your database details.
4.Import the SQL from sql.txt
5.Upload all the files to your root and boom, your done.

Download:
Code:
http://www.sendspace.com/file/ic6laf

VirusTotal:
Code:
http://www.virustotal.com/file-scan/report.html?id=dbb62d06917c1d1e58ca42443aa79f471d9ff366fb353c9aa2099280ab5257c8-1319579205

Enjoy
 
Last edited:
Doesn't work, I just get the errors

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/******/public_html/*****.CO.UK/includes/lilurl.php on line 73

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/******/public_html/*****.CO.UK/includes/lilurl.php on line 123

Both these lines contain the code : if ( mysql_num_rows($result) )
 
Doesn't work, I just get the errors

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/******/public_html/*****.CO.UK/includes/lilurl.php on line 73

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/******/public_html/*****.CO.UK/includes/lilurl.php on line 123

Both these lines contain the code : if ( mysql_num_rows($result) )



Drop everything in your database and then import this sql, if it works let me know and i can edit the original. Make sure you edit the database name :
Code:
-- phpMyAdmin SQL Dump
-- version 3.4.5
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 25, 2011 at 01:14 PM
-- Server version: 5.1.56
-- PHP Version: 5.2.9

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `YOUR-DATABASE`
--

-- --------------------------------------------------------

--
-- Table structure for table `lil_urls`
--

CREATE TABLE IF NOT EXISTS `lil_urls` (
  `id` varchar(255) NOT NULL DEFAULT '',
  `url` text,
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
 
Wow, genius, that worked perfectly :D Thank you very much...
 
great I would love to try this one.
few questions
can we sue it on subdomains as well like,
a.abc.com/asd
 
great I would love to try this one.
few questions
can we sue it on subdomains as well like,
a.abc.com/asd

I have not tested it on a sub domain. It should work but you may well need to edit the htaccess file accordingly.
 
Thanks, but my shortened URL has two forward slashes! eg http://zcu.be//1

How can I fix this?

Cheers :)

edit: to clarify, the link given is: http://zcu.be//1, but http://zcu.be/1 (with one forward slash) also works. Looking into the code to try and edit this myself but if you find it first let me know please!
edit2: found it - line 42 of index.php. Change

PHP:
$url = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).'/'.$lilurl->get_id($longurl);
into
PHP:
$url = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']).''.$lilurl->get_id($longurl);

Notice how the '/' has been changed to '', removing the forward slash.

Thanks again - nice little script!
 
Last edited:
Great share! Now if I could only find a nice catchy short domain name.
 
I would advice anyone against monetizing this, competition is too fierce because this is way too easy to do. When a complete noob from BHW can do something, it's something to stay away from ;) use it for personal use
 
This is not to monetize.
It's to manage your own short URLs, especially for CPA, ...

Except as to ******, monetize an URL shortener is not a good idea... (IMHO)

Beny
 
Great script.

You can also host multiple domains like domain1.us, domain2.us, domain3.us etc on 1 hosting account all sharing one database.

That way domain1.us/1/, domain2.us/1/, domain3.us/1/ will all go to the same url. Great if some sites are blocking some of your domains - you don't have to go and shorten the link again, you just change the domain and the link will go to the same place.
 
How do these make money anyway?

They don't really make money. Certain things require short URLs, such as twitter or any other short-message clone. The problem is people using goo.gl or bit.ly sometimes have their campaign banned and URLs destroyed by these URL shortener places who don't like being used for blackhat or SEO purposes.

Controling your own URL shortener limits your liabilities by keeping 100% of the control of your shortened URLs in your own power.

Furthermore (and this is something I'm considering in the future) ... if you do a whole ton of spam links to one URL and for whatever reason that spam is unsuccessful (the domain becomes deindexed, it just doesn't rank that well, you have another idea for the spam), you can instantly divert 5k, 10k, 100k, even a half million links or more all by switching a 301 from going from one destination to another.
 
Furthermore (and this is something I'm considering in the future) ... if you do a whole ton of spam links to one URL and for whatever reason that spam is unsuccessful (the domain becomes deindexed, it just doesn't rank that well, you have another idea for the spam), you can instantly divert 5k, 10k, 100k, even a half million links or more all by switching a 301 from going from one destination to another.

I wasnt gonna say, but whenever somebody rips my site, 50% of the time they go and use my url shortner.

So as my way of saying "fuck you" for stealing my site, i just swap their links and point them to my sites. :D
 
Nice I'll give this a try...

What would be even cooler is if someone on here could make a quick redesign of the homepage to make it "sparkle".

Have the appearance of a REAL URL shortner so that if someone hit the site they'd assume it was a normal, new, URL shortning service.

Heck, maybe you PW protect it or something along those lines so no one else uses it and have the page be in "private beta"...

Either way, nice share....
 
Back
Top