How can use mod_rewrite to redirect a multiple specific URLs containing multiple query strings?

Posted by Derek on Server Fault See other posts from Server Fault or by Derek
Published on 2011-01-14T15:45:21Z Indexed on 2011/01/14 15:54 UTC
Read the original article Hit count: 210

Filed under:
|
|
|
|

Hi there folks, we recently migrated a site from a custom CMS to drupal. In an effort to preserve some links that our users bookmarked (we have about 120 redirects) we would like to forward the original URLs to a new URL.

I have been searching for a couple days, but can't seem to find anything simple to what I need.

We have existing URLS that contain one or more query strings, for example:
/article.php?issue_id=12&article_id=275

and we would like to forward to the new location:
http://foobar.edu/content/super-happy-fun-article

I started using:

RewriteEngine On  
RewriteRule ^/article\.php?issue_id=12&article_id=275$ http://foobar.edu/content/super-happy-fun-article [R=301,L]  

This, however, does not work.

A simple RewriteRule works:

RewriteRule ^test\.php$ index.php  

It is unclear to me how I need to use {QUERY_STRING} with multiple

Basically it's 120 simple redirects that go from one existing URL to a new one. I don't need ranges [0-9], because there is no sequential order to existing URLs.

Perhaps I can do what I need with RewriteMap and a simple text file that contains a line like this:

index.php?issue_id=12&articleType_section=0&articleType_id=65 http://foobar.edu/category/fall-2008

If anyone has any idea on using mod_rewrite to accomplish this or if there is a better, or more simple mod, I am open to that as well.

Thanks!

© Server Fault or respective owner

Related posts about apache

Related posts about mod-rewrite