Redirectmatch - help

I need to write a redirect match for this
http://mysite.com/ds/index.jsp?contloc=dash-viewdashboard&id=008 http://www.google.com
http://mysite.com/ds/index.jsp?contloc=dash-viewdashboard&id=025 http://www.yahoo.com.
I tried different options nothing is working …can some one help

RedirectMatch 301 /ds/index\.jsp([a-z_\-=?&]+)(.*)$ http://www.google.com

pal,

First, WELCOME to SitePoint’s Apache forum!

From all the questions about mod_alias with a query string, I’ve got to assume that mod_alias (all the Redirect series) cannot view the query string. THEREFORE, you’ve got to fall back on mod_rewrite’s RewriteCond to match the {QUERY_STRING} and RewriteRule to redirect.

If you need coding examples, there plenty in my signature’s tutorial and this board’s sticky threads. If the code you develop does not work right away, post it here and I’ll help correct it.

Regards,

DK

I tried this

RewriteCond %{QUERY_STRING} ^contl(.)$
RewriteRule ds/index.jsp(.
) http://www.google.com? [R=301]

also I am not sure how to differentiate the first one from second ?

http://mysite.com/ds/index.jsp?dashboard&id=008 –>http://www.google.com
http://mysite.com/ds/index.jsp?dashboard&id=025 —>http://www.yahoo.com.

Hi pal!

Okay, basic disconnect(s):

  1. Use of (.*) is dangerous and should be reserved for the few cases where you NEED to capture EVERYTHING.

  2. Trying to match contl{garbage} is VERY different than dashboard & id-008 or 005! What is “contl(.*)” supposed to match?

  3. If you want to ensure that you’re only matching the dot character (unless within a character range definition), ESCAPE the dot character!

  4. Ditto the {garbage} AFTER index.jsp! What is that supposed to match? Remember, the RewriteRule directive can only compare the regex against the {REQUEST_URI} variable, i.e., everything after the domain and before the query string delimiting marker, ?. Okay, okay, because (.*) will also match NOTHING, this instance is not likely to cause you any problem - unless you’re using MultiViews and there IS something after the index.jsp.

  5. It’s odd that the key, "dashboard ", has no value.

Happy New Year!

RewriteEngine on
RewriteCond %{QUERY_STRING} ^dashboard&id=008$
RewriteRule ^ds/index\\.jsp$ http://www.google.com/

RewriteCode %{QUERY_STRING} ^dashboard&id=025$
RewriteRule ^ds/index\\.jsp$ http://www.yahoo.com/

Regards,

DK