I am working on a URL shortening site which uses PHP, MySQL and Apache. General idea of URL shortening as I look at open source projects: user gives a URL link and the syste
I think you are quite on the right way.
One thing I would not do like you said, though, is about this part :
then use apache mod_rewrite and create shorten url and then redirect.
I don't think I'd create an Apache RewriteRule, nor use mod_rewrite
.
When receiving an short url, like short.com/MYID
, Id would :
A bit like this I guess :
// fetch $urlFull from DB (corresponding to the MYID received in GET)
header('HTTP/1.x 301 Moved Permanently');
header('Location: ' . $urlFull);
die;
(edit) If by mod_rewrite
you meant "transform short.com/MYID to short.com/id=MYID", oh, yes, in this case, of course !
I'm using something like this on one of my sites, btw :
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php?hash=$1 [L]
Hope this helps :-)