Forum Moderators: phranque
So far I have this:
RedirectMatch 301 ^(.*)cgi-bin/file.cgi?s=(.*)&v=(.*)$ $1subdir/$2/$3 Even if the code worked, it wouldn't change the .zip to .html, so I need help with that too. The original file extension won't always be .zip, but it will be three characters. The line is in the .htaccess file in the home html directory.
"?" is a special character when used in a regular-expressions pattern. If you wish to match a literal question mark, as you do in your RedirectMatch pattern, you need to precede it withj a "\"
RedirectMatch 301 ^(.*)cgi-bin/file.cg[b]i\?s[/b]=(.*)&v=(.*)$ $1subdir/$2/$3
Jim
If you can use mod_rewrite, the following code should be equivalent to RedirectMatch 301 ^(.*)cgi-bin/file.cgi\?s=(.*)&v=(.*)$ $1subdir/$2/$3:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^s=([^&]*)&v=(.*)$
RewriteRule ^([^/]*)/cgi-bin/file\.cgi$ /$1/subdir/%1/%2? [R=301,L]
The mod_rewrite code I posted is an exact replacement for your Redirect 301 directive. The [R=301] in the RewriteRule forces an external 301 Redirect, and the [L] flag forces the redirect to occur immediately without any further mod_rewrite processing.
Unless I typed it wrong, it should do exactly the same thing as you intended to do with your original code.
Jim