need an advice! here is a what I know about url shortening:
usually new records id is taken from Database and converted to something, let’s say base 36…
My situation:
I need to have a additional feature in URL shortening along with auto generated url I also need to be able process custom url.
Example: user enters : http://google.com and wants to have short url “domain/my-google”.
Problem:
things are fine at the first sight, but I am worried about scaling, as urls will be stored for 90 days and if database records will grow! I might face some performance issues!
So the question: What approach should I take while processing (creating/ serving) custom short urls?
This is a series of complications for you. With a little htaccess coding and a couple lines of PHP litterally a very tiny script for the over all use of parsing the URL and getting the pieces from it is the easy part. As for the short url id’s thats a whole nother can of worms. if you go stricly INT based and use numerics for your concept such as with an auto-incriment column for the ID’s to use as the short part of the URL things are easy, things will always be unique, and no serious worries about bashing ID’s where doubles and triples can come up.
here is what I have used several times over
.htaccess php how-to wordpress slugs And it always works well for me. Handling the rest of it though Ill leave to your construct and logic desired bare in mind your going to query a DB in the end run, so make sure your query gets sanitized as the trailing bit of the URL that would be the ID is based on user input.