Click to See Complete Forum and Search --> : Mass redirects?


SWilson
06-27-2008, 12:49 PM
I'm doing a website for a writer. She has 400-500 articles that will be databased, however, she has links to these articles from her old site and those links must remain intact. So, I have 400-500 redirects I need to set up, like:

http://www.ilanamercer.com/HonestAbesAnguish.htm

needs to go to

http://www.ilanamercer.com/phprunner/public_article_list_view.php?editid1=31

I know how to redirect a single url but is there a way I can set up a single file to handle this for me? If so, would someone point me in the right direction?

Thanks,
Susan

tfk11
06-28-2008, 02:06 AM
You could use mod_rewrite to handle the redirect. Add a rewrite rule to your .htaccess file that redirects any requests for htm files to your script. The script will then have to to determine what story to show based on the name of the htm file requested.

RewriteRule ^(.*).htm$ /index.php?htm=$1

You'll probably want to use another database table to store the associations between the htm filenames and story ids. So in your script do something like...


if( isset($_GET[htm]) )
query( SELECT story_id WHERE htm_filename = $_GET[htm] );
if( match found )
show the story