Forum Discussion

mbuk2k_59598's avatar
mbuk2k_59598
Icon for Nimbostratus rankNimbostratus
Aug 16, 2012

301 Redirect Not Working

 

OK, we need to redirect the following using a 301: http://www.ourwebsite.co.uk/mall/departmentpage.cfm/customer/_249553/1/Product1 to http://www.newwebsite.co.uk/product/Product1 I've tried using the F5 iRule redirection generator which gave me: when HTTP_REQUEST { if {[HTTP::uri] equals {http://www.ourwebsite.co.uk/mall/departmentpage.cfm/customer/_249553/1/Product1}} {HTTP::uri {http://www.newwebsite.co.uk/product/Product1} } } Which didn't work. Any help would be kindly appreciated. Thank you

 

 

 

  • I've also tried the following and although the syntax was accepted by the F5 like the iRule above, the actual redirect didn't work:

     

     

    when HTTP_REQUEST {

     

    if {([HTTP::host] equals "www.ourwebsite.co.uk") && ([HTTP::uri] equals "/mall/departmentpage.cfm/customer/_249553/1/Product1")} {

     

    HTTP::respond 301 Location "http://www.newwebsite.co.uk/product/Product1" }

     

    }

     

     

    Please let me know if anyone has any suggestions, thank you.
  • All of a sudden picked up and started working, it might have been that I needed a / on the end of Product1
  • Richard__Harlan's avatar
    Richard__Harlan
    Historic F5 Account
    If you run into problem and are trying to troubleshoot issuse I throw in some debug statments to make sure what I think it should be seeing is what it is seeing.

     

     

    if you case you can run a quick log statment

     

     

    log local0. "HTTP Host = [HTTP::host] HTTP uri = {HTTP::uri]"

     

     

    In more complex iRules you can leave the log statment in place and use a debug value to turn them on and off like below

     

     

    set debug 0

     

    if ($debug) {

     

    log local0. "debug message"

     

    }

     

     

    This way the only time you log anything is when you set your iRule to debug. You can even set different level and only turn some on depending on what level you set.