If you want to hard-code the URLs into your .htaccess
file you can simply set up static redirects:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=320(.*)$
RewriteRule /website$ /terna [L,NC]
RewriteCond %{QUERY_STRING} ^id=321(.*)$
RewriteRule /website$ /somewhere-else [L,NC]
</IfModule>
However if you want to make it more flexible (maybe let people change their own redirects, or similar) you'd need to store it in a database (redirects
table, columns of website_id, redirect_url
) then when someone queries, do this (pseudo-code):
if (isset( queryString['id'] ))
query( SELECT redirect_url FROM redirects WHERE website_id = queryString['id'] )
redirectTo( redirect_url );
exit
In PHP, the actual redirect would be done with header('Location: ' . $redirect);
, and the query part should be easy enough.