[Full Guide] Install YOURLS And Create Your Own Short URL Service

Nowadays you must be using short URL service like bit.ly or goo.gl to shorten any long URL so that you will be able to share those short URL across various social networking sites like Twitter which has word limit.

There are several online services which allows you to convert any but what about your own short URL service, today we are going to see how you can make your own short URL service.

Requirements :-

  • A short domain
  • YOURLS
  • A server with PHP 4.3 and MYSQL 4.1 and above with mod_rewrite enabled.
  • Few free minutes, and
  • A cup of coffee

Short Domain :-

Getting a short domain is little tricky and you might have to spend hours to get a short URL, you can try for .CO, .PW domain or you could also refer to Country Code Top Level Domain like .IN, .ME, .AR, .AS and so on, these Cc TLD are expensive so plan your domain accordingly.

You can get a one for you from BigRock. Once you have a domain you are ready to go.

YOURLS :-

YOURLS is a little php script which allows you to convert your long URLS into short one, it’s a server-based web app and if you ever used WordPress then you wont feel any difficulty to install it. You can download a copy of YOURLS from HERE.

Getting things ready :-

Login to your cPanel and create a new database, you can name it anything which you want but remember it as we need it very soon.

Now unzip YOURLS downloaded files and navigate to User folder where you will find config-sample.php file, open it in a text editor, I prefer Notepad++ and edit following details :-

  • YOURLS_DB_USER :- Your database username which we had just created
  • YOURLS_DB_PASS :- Password for your database
  • YOURLS_DB_NAME :-Your database name
  • YOURLS_SITE :- Your short URL which you had purchased (make sure you leave off trailing slash)
  • username & password :- whatever username and password you want to keep for admin

YOURLS_Config

Now save that file and rename it to config.php from config-sample.php and upload whole directory to your server and sit back and grab coffee as it will take few minutes. Once all files are uploaded open your web browser and type yoururl.com/admin/install.php

If you had did above mention things as it is then you will see following message :-YOURLS_Installed

Now once you had installed YOURLS its time to navigate yoururl.com/admin and login with your credentials and from here you can generate short URL for yourself.

YOURLS_Admin_panel

Redirect Short URL to Main Domain :-

You must want if anyone type yoururl.com so he/she must be taken to your main domain as he has nothing to do there, so in that case you need to add following line to your .htaccess file which you can find on your root directory.

<IfModule mod_rewrite.c>

RewriteCond %{HTTP_HOST} ^youurl.com$ [OR]

RewriteCond %{HTTP_HOST} ^www.yoururl.com$

RewriteRule ^/?$ http://www.maindomain.com [R=301,L]

</IfModule>

This will keep your SEO and will redirect to main domain if someone type incorrect URL

Generate random URL :-

One problem which I faced with YOURLS is that first it start with numbers like yoururl.com/1, yoururl.com/2 and so on but if you want to generate random URL for your URLS like yoururl.com/f1d4f and so on the you need to install a Random Keyword plugin. You can get from Here.

Integrate with your WordPress :-

Now we have running short URL domain, at last we just need to integrate it with our exiting WordPress blog, for this you just simply need to download and install WordPress Plugin and then in setting give your credentials.

YOURLS_Wordpress_Setting

For me when I try to enter my credentials it keep giving invalid username and password error, a simple solution for this is that you can create a new username and password by adding it to your config.php file.

That’s it, now over a time this plugin will grab all blog post and generate there short URLs automatically.

If you have any question then let us know through comment section, we will try to answer them as soon as possible.

Some handpicked devices for you