Mod rewrite rules and querystring parameters in Drupal
21st Dec 2007
Mike Dixon
Senior Mind
Hey, you seem to look at this article a lot! Why not Bookmark this article so you can find it easily in the future?
Just a quick one this, and not strictly Drupal related - but might save you some time when you are writing modrewrite rules to rewrite legacy URLs.
The problem : We had a whole bunch of legacy URLs in the format index.php?Page=SomePageHere which we needed to rewrite to point at some shiny new Drupal URLs.
A simple RewriteRule wasn't working, and after a bit of digging we discovered you can't reference the querystring within a RewriteRule ...
The solution is to use RewriteConditions, so you end up with something like
RewriteCond %{QUERY_STRING} Page=SomePageHere
RewriteRule ^index.php$ new-page-url-here? [R=301,L]
And jobs a good un!