Htaccess - why doesn't this 301 redirect work?

I have an htaccess file in the root directory of a site, and it contains a number of 301 redirects, most of which work fine. But some do not. Here’s an example:

Redirect 301 /page/?qs=query_string

Please note that, in this example, “/page/” is an actual page in and of itself (there’s a document “/page/index.php”). When I put “/page/?qs=query_string” in the location window of my browser, nothing in the URL changes, and the page displays the “/page/” content as if there were no query string in the URL. The second part of that is actually to be expected, since the page isn’t looking for the variables in the “bad” query string, but why isn’t it redirecting?

Suffice it to say that I’m not an expert on redirects, so thanks for any help!

Hmmm, it appears I have to use mod_rewrite, as 301 redirects can’t deal with query strings? I’ll try that.

This worked:

RewriteEngine on
RewriteCond %{QUERY_STRING} =qs=query_string
RewriteRule ^page/$ /page.html? [L,R=301]

Indeed, simple redirects don’t work on / ignore the query string, you need mod_rewrite for that. Nice catch! :tup: