Short URLs come in handy for most webmasters. There are multiple costs involved in running a URL Shortener Service. In this article, I will show you how to Setup a URL Shortener Website for free i.e., you won’t have to pay for PHP scripts with this tutorial. I will also show you how you could setup an intermediate Ad Page with Timer on your URL Shortener Service.
Why do you need a URL Shortener in 2020?
Let’s say you have a very popular article about “advantages and disadvantages of organic farming” on your blog. This article’s URL is http://website.com/organic-farming-advantages-disadvantages. Now, consider this for a URL – http://website.com/org-farm which redirects to http://website.com/organic-farming-advantages-disadvantages.
The shorter one can be easily remembered and moreover, since we are just redirecting, you don’t lose the advantage of having your keywords in the URL. The shorter one makes it easier to share your articles offline too.
Moreover, with the intermediate Ad Page, you could also make some extra money.
URL Shorteners are also extremely helpful if you do a lot of affiliate marketing as these URLs can be used to cloak your affiliate links.
- YOURLS Script
- YOURLS Interstitial Plugin
Domain – How to choose and where to buy?
To first thing you’d need is a domain. Your decision here needs to be wise. Make sure you get a small domain. Having a domain name such as urlshortenerfree.com contradicts the whole purpose of having a URL shortener. So, here are a few tips to follow:-
- Choose a small domain name, maybe, 4-5 letters long. If the URL shortener is for a specific website of yours, try to buy a domain that matches
- Choose a small extension. Just choosing a small domain name, wouldn’t work. For eg:- urlsh.in vs urlsh.online. Which one would you choose?
You can get a .xyz domain for just $1 (first year) at Namecheap.
The best part about buying from Namecheap is you get SSL and Whois Privacy Guard free of cost. You may also try other short domains like .in, .io. Domains start at $0.88 at Namecheap.
To host our website, we will require a good hosting. While the preferred is VPS hosting, if you plan on starting out small, go for a shared hosting plan. There are multiple providers out there. If you’ve had a good experience with any of them, go for it. Else, you may try Namecheap.They currently are selling hosting plans at a 50% discount.
With the plan, you also get Namecheap VPN free for 30 days.
If you plan on going with Shared Hosting, you may choose the beginners Stellar Plan which offers 20GB Disk space, 3 domains, unlimited bandwidth, etc.
We are going to use YOURLS Script for our Link Shortener Service.
Advantages of YOURLS
- Highly customisable.
- Lots of plugins.
- Analaytics and Stats feature inbuilt.
YOURLS Interstitial Plugin
Using this plugin, we will run our intermediate Ad page with timer similar to what services like AdFly do. Download the plugin here.
Setup URL Shortener Website/Service in 2020
Now, let’s begin the actual process of installation and setup. Follow these steps in the same order as below:-
There are multiple ways to install YOURLS depending on the hosting you have chosen.
Install YOURLS with Softaculous
Almost all hosting providers have Softaculous Installer in the CPanel. Contact your host to find out. Namecheap’s CPanel has it. So, on your CPanel, go to Softaculous and install YOURLS. Just follow the directions properly. Make sure to choose a good username and password.
Install YOURLS manually
- Go to your website’s CPanel. Using MySQL Database Wizard, create a Database and a corresponding user. Make sure to note down the MySQL Database Name, Username and Password.
- Download YOURLS script here. Extract it.
- In the folder user, rename config-sample.php to config.php.
- Open config.php with your favourite editor and make changes in the following lines:-
define( 'YOURLS_DB_USER', 'your db user name' );– Replace
your db user namewith MySQL Database’s username.
define( 'YOURLS_DB_PASS', 'your db password' );– Replace
your db passwordwith MySQL Database’s password.
define( 'YOURLS_DB_NAME', 'yourls' );– Replace
yourlswith MySQL Database name.
define( 'YOURLS_DB_HOST', 'localhost' );– Replace
localhostwith server name. localhost is default for most. Contact host if localhost doesn’t work.
define( 'YOURLS_SITE', 'http://your-own-domain-here.com' );– Replace
http://your-own-domain-here.comwith your domain name. Do not add a trailing slash (/) after the domain.
define( 'YOURLS_COOKIEKEY', 'modify this text with something random' );– Replace
modify this text with something randomwith anything you want. Just make it long.
'username' => 'password',– Modify
usernamewith anything you like and
passwordtoo. Make sure they aren’t easy to guess.
- Once edited, save the file and upload all the contents inside the YOURLS folder containing folders such as admin, css, etc to your server using CPanel’s File Manager or FTP. Remember to upload only the contents of the folder, not the folder itself.
- Now, on your web browser, go to http://yourdomain.com/admin and this will install YOURLS.
- To check, go to http://yourdomain.com/admin and now it will ask for your username and password. Enter and try to shorten links.
If you just wanted a redirection service without an intermediate Ad Page, then you can stop here. Else, continue.
Setup Ad Page with Timer on YOURLS
- Browse to user/plugins on your website server using CPanel’s File Manager of FTP.
- Within plugins folder, create a folder named interstitial.
- Extract YOURLS Interstitial Plugin.
- Upload all the contents of folder yourls-interstitial-plugin-master i.e., css, img, plugin.php and template.html to the interstitial folder we just created.
- Go to http://yourdomain.com/admin and click on Manage Plugins on top left.
- To the right of Joel’s Interstitial Plugin for YOURLs, under Action, click Activate. That’s it!
- Check by going to a Short URL.
Now, you will see default set content and logo appearing. You can change all of that.
Setup Ads and Logo in YOURLS Interstitial Plugin
- On your server, browse to user/plugins/interstitial.
- To setup ads, open template.html with a text editor and replace
%ad%with your Ad code.
- To replace logo, browse to img folder within interstitial folder and replace logo.jpg with your logo.
All the changes you want to make to the Ad page like increasing or decreasing the timer period, changing the feel and looks can be made in template.html and the related interstitial.css within css folder.
There’s a lot of scope for customisation when it comes to YOURLS. So, I might come up with more related articles. Till then, keep experimenting with multiple plugins available for it. Hit a roadblock? Comment below!