You may want to have a DB with the fields "ID" and "URL", where ID is some autoincrement value, and URL the URL you want to redirect to.
The you build yourself a redirect script (e.g. called redirect.php
):
<?php
// some configuration
if (!empty($_SERVER['PATH_INFO'])) {
$_GET['id'] = substr($_SERVER['PATH_INFO'],1);
}
if(!empty($_GET['id'])) {
// You have to build a function which returns the URL from DB for this ID
// Remember: You new complete URLs for redirects
$url = get_url_for_this_id($_GET['id']);
if (!empty($url)) {
header('Location: '.$url);
exit;
}
}
echo('No URL found');
?>
And the user calls your script like:
redirect.php/1234
or redirect.php?id=1234