I need to setup hundreds of short redirect URLs which follow this format:
http://mysite.com/shorturl
which will redirect to
http://mysite.com/index.php?id=N
, where N is the ID corresponding to that shortcut.
What's the best way to do this.. should I be writing a ModRewrite line for each individually, or is there a better way to do this that incorporates storing a column in the database or a file?
Update: to clarify, the id N is an ID in the database. The shorturl is a small phrase used for linking people to the page corresponding to that ID.
Is there a reason why you didn't want to do something like making
http://mysite.com/shorturl
redirect to
http://mysite.com/index.php?id=shorturl
And index.php
can look up the correct id
in the database from the shorturl
and do the right thing.
Obviously, to do this, all you'd need is one line in your .htaccess:
RewriteRule ^([A-z,0-9,_,-]+)/?$ index.php?id=$1 [PT]