Forum Discussion

Bob_10976's avatar
Bob_10976
Icon for Nimbostratus rankNimbostratus
Jun 07, 2012

Odd WWW Redirect and Uppercase issue..

Hello all, I've got an odd issue with one redirect not working and it seems because the URI has uppercase in it.I have a couple of redirect in place which is below but the problem is if I go to http://www.mydomain.com/Portal/OrgList.aspx it won't redirect however if I use http://www.mydomain.com/portal/orglist.aspx it will.

This is www redirect rule:


when HTTP_REQUEST {
switch "[string tolower [HTTP::host]]" {www.mydomain.com {
HTTP::respond 301 Location "http://mydomain.com[HTTP::uri]"
}
}
}

This is the specific section of URI redirect rule:


elseif { [string tolower [HTTP::uri]] starts_with "/portal/orglist.aspx" } {
     HTTP::respond 301 Location http://mydomain.com/government/pages/agency.aspx
 }
 

I even tried changing the "starts_with" to Equals but didn't change anything, and I attempted to remove the [string tolower... section but I get an error indictating that is not a vaild rule.

Any suggestions or thoughts on what I'm doing wrong?

Thanks,

Bob

  • Hi Bob,

    From what you are describing it should work properly. Thing that I can notice from what you have provided is that your "www.mydomain.com" is not enclosed in "".

    Try something like this:

    
    when HTTP_REQUEST {
    switch [string tolower [HTTP::host]] {
    "www.mydomain.com" { 
    if { [string tolower  [HTTP::uri]] ends_with "/portal/orglist.aspx" } {
    log local0. "Qualified Match: [HTTP::uri]"
    HTTP::respond 301 Location "http://www.google.com"
    }
    }
    }
    }
    

    These were my logged results:

    Jun 7 13:29:06 local/tmm info tmm[30731]: Rule Z.iRule.Development : Qualified Match: /Portal/ORGList.aspx

    Hope this helps.
  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    Your snippet contains "elseif". Is it possible that there's another condition that is being met earlier in the code?