redirects with * on the end....not working

basic redirect with a twist. I thought my little * symbol would mean ANYTHING after the =, no matter what, redirect to the new site…but it doesnt. im looking into maybe needing a single quote around it or something. Ill be off reading about tcl and wildcards. any tips would be appreciated.

“ecms.epa.gov/erma/login.htm?action=search&token=*” { HTTP::redirect “https://ecms.epa.gov/erma2/login.htm?action=search” }

Thanks!

Dave

…it works if I remove the star…

Is globbing enabled? Are you checking specifically for the URI? Something like this should work:

switch -glob [string tolower [HTTP::uri]] {
  "/erma/login.htm?action=search&token=*" {
    HTTP::redirect "https://ecms.epa.gov/erma2/login.htm?action=search"
  }
  default {
     do something else
  }
}

Hi,

the “starts_with” comparison should do the job:

when HTTP_REQUEST {
   if {[string tolower [HTTP::uri] starts_with "/erma/login.htm?action=search&token="} {
       HTTP::redirect "https://ecms.epa.gov/erma2/login.htm?action=search"
   }
}

Please keep in mind, that query parameters in different order will break the logic.

With

[HTTP::path]

and

[HTTP::query]

you have access to the URI components.

Use

[string tolower ]

to be case insensitive.

Thanks, Stephan

Thanks, guys. I decided to go with glob because I was already using a switch statement, and it did in fact work, so that is great. Now im getting questions on why it worked, and frankly, I dont have a clear answer. It seems the glob command reads a filename more directly. not really sure. any explanations on why this worked??

anyway, the important thing is the site redirects now, thanks so much for both solutions.

dave

glob

as a standalone command in Tcl is somewhat different than

-glob

as an option to

switch

.

Switch

https://www.tcl.tk/man/tcl/TclCmd/switch.htm (see

string match

for a more detailed description: https://www.tcl.tk/man/tcl/TclCmd/string.htm)

glob

https://www.tcl.tk/man/tcl/TclCmd/glob.htm