How do I create a site similar to TinyURL using Apache ?

nainil used Ask the Experts™

I want users to visit my site, provide a LONG URL and my site should convert it to a short URL. How do I accomplish it using Apache?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You will need a database.  Users will enter the long url which the database will store along with a 2nd field which is a randomly generated short text.  When users click on the short link they are directed briefly to your site, the database runs quick lookup and then redirects to the actual site.

I haven't used this script myself but does exactly what you are seeking:


To webjinks:

It seems the project has been out-of-sync for a while. I thought there is no need for MySQL as all of this could be done through Mod-ReWrite. Any comments?
Acronis in Gartner 2019 MQ for datacenter backup

It is an honor to be featured in Gartner 2019 Magic Quadrant for Datacenter Backup and Recovery Solutions. Gartner’s MQ sets a high standard and earning a place on their grid is a great affirmation that Acronis is delivering on our mission to protect all data, apps, and systems.

I must admit that I simply read the description and sent link.
You will need a database because you need to store records of the long and short URL.
Technically it's not the only option short of writing each apache rule for each URL or using a text file but do not recommend anything else except for database because of ease, security and speed.

Here are 7 free scripts that look very promising.

This one was updated yesterday:
Budi SantosoIT Infrastructure Manager

The easiest one is creating script to create folder with short name input contained with index.html that redirecting to long url.
Don't forget to add captcha.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial