If you want to shorten a URL, you either use only a .htaccess file or a combination of a .htaccess file and a PHP script.
The basic principle:
- Either admins or visitors (I don't know why you need to shorten URL's, perhaps as service or for usage on your own site) can enter a URL in some kind of form,
- When the form is submitted:
first it is checked whether the URL already exists, if so display the already generated short URL (e.g. tinyurl.com/1c2).
If the URL does not yet exist in the database, insert the URL into the database, then retrieve the last database entry's ID (this is either in hexadecimal or decimal) and then show the created URL to the user.
- Your .htaccess file should be something like this:
RewriteRule ^([A-Za-z0-9]+) /redirect.php?turl=$1 [NC]
- And then you have redirect.php that retrieves the turl from the database, and then directs the user to the original URL (with the Header() function for example)
If you do not have the programming experience to do the above, either hire someone or find a shorten url script somewhere (although they do not grow on trees)