lucy24 - 1:01 am on Apr 5, 2013 (gmt 0)
You cannot use mod_alias (Redirect by that name) because it works only on paths, not on queries. So you must use mod_rewrite.
Once you are in mod_rewrite you have two choices. You can redirect, meaning the browser's address bar changes, or you can rewrite, meaning it doesn't.
You currently have nice URLs that look like
If the page content lives at
... now wait a minute. What do you mean, .html?blahblah ? HTML pages don't have queries. Do you have a secret php file in the background? If so, you already have rewrites going on and you need to dump mod_alias yesterday. Or are you simply parsing html as php? Messy...
There are two questions: What to do and how to do it. You have to answer the "what" before the "how".
"What to do?" = Do you want the user's browser address bar to change? AND Where does the page content "really" live?
Let me assume for the sake of discussion that your content really lives at
I do not think anyone hereabouts will advise you to REDIRECT users from the old pretty-good URL to the new not-so-good one. In fact, crystal ball says that within 48 hours there will be a post from g1smd extolling extensionless URLs. Personally I don't care for them. "Go back in the server and put some clothes on!" is my gut reaction.
If the users don't see the "real" filename, there is no need to parse html as php; your files can use honest extensions. All it takes is a single conditionless rule that looks something like this
RewriteRule widget_(\d\d\d\d)\.htm /newwidget.php?stock=$1 [L]
You may want a redirect going in the other direction-- but if nobody has ever seen the form with the query string, you probably don't need one.