Forum Discussion

nrg2brn_163859's avatar
nrg2brn_163859
Icon for Nimbostratus rankNimbostratus
Mar 23, 2015

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

 

5 Replies

  • 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