Forum Discussion

dcam_21053's avatar
dcam_21053
Icon for Nimbostratus rankNimbostratus
Sep 17, 2012

URL Redirect Not Working

I am not sure why, but can someone look at this redirect irule and tell me what I am doing wrong. It is a seemingly simple thing. I am seeing that the irule is being hit, no errors, and the VIP is being hit of course, but there is no redirect happening. It keeps sending me to the original site.

 

 

 

when HTTP_REQUEST {

 

if { [HTTP::uri] equals "site/care/ccso" } {

 

HTTP::uri "http://site/sites/ccsops/"

 

}

 

}

 

  • a URI will always starts with "/". Also assuming "site" is you host name. So:

    
    when HTTP_REQUEST {
        if { [HTTP::uri] equals "/care/ccso"  } {
            HTTP::uri "/sites/ccsops"
        }
    }
    

    Also remember that HTTP::uri will transparently redirect the URI. The user won't see this in the browser. If you want something more explicit, try HTTP::redirect "http://site/sites/ccsops/".

  • I tried it the way you suggested and it still not doing a redirect.
  • Okay, do this:

    
    when HTTP_REQUEST {
        log local0. "URI = [HTTP::uri]"
        if { [HTTP::uri] starts_with "/care/ccso" } {
            HTTP::uri "/sites/ccsops/"
        }
    }
    

    I added a logger line. View that either through the LTM log in the management UI or by tailing the /var/log/ltm file in the shell. I also change the HTTP::uri conditional to "starts_with" instead of "equals" on the hunch that your URI isn't exactly what you're looking for.

    Now, do you want the browser to explicitly redirect to the new URI, or do you want the browser's address bar to same the same but still go to this new URI?

  • I would like the browser to explicitly redirect to the new URI....

     

     

    I should have mentioned this before, not sure if it matters though. The site is actually going to Sharepoint...the url hits the site and the content is fetched from a database.
  • Thank you, with your help I was able to get it to work...it is now redirecting properly. I ended up using the operator "contains"
  • Want some more details about this is not working if we putted it properly....