Forum Discussion

Dishant_298426's avatar
Dishant_298426
Icon for Nimbostratus rankNimbostratus
Dec 09, 2016
Solved

URL Redirection IRule

  • Hi Dishant, you can try this:

    (Thanks to Stanislas - using respond, relative path and not use string to lower in case its not necessary)

      when HTTP_REQUEST {
        if { (([string tolower [HTTP::host]] contains "www.pitneybowes.us") and ([HTTP::uri] equals "/shop/ink-and-supplies/postage-meter-ink-and-supplies/for-dm100i-dm125-dm225/en-us/storeus")) {
            HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"
        } 
    }
    

3 Replies

  • Hi,

    try this:

    when HTTP_REQUEST {
        if { [HTTP::host] equals "www.pitneybowes.us" && [HTTP::uri] equals "/shop/ink-and-supplies/postage-meter-ink-and-supplies/for-dm100i-dm125-dm225/en-us/storeus" } {
            HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"
        }
    }
    
  • Hi Dishant, you can try this:

    (Thanks to Stanislas - using respond, relative path and not use string to lower in case its not necessary)

      when HTTP_REQUEST {
        if { (([string tolower [HTTP::host]] contains "www.pitneybowes.us") and ([HTTP::uri] equals "/shop/ink-and-supplies/postage-meter-ink-and-supplies/for-dm100i-dm125-dm225/en-us/storeus")) {
            HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"
        } 
    }
    
    • Stanislas_Piro2's avatar
      Stanislas_Piro2
      Icon for Cumulonimbus rankCumulonimbus

      Hi,

       

      Please never include protocol and hostname in HTTP redirect if target service is the same as source service...

       

      As the source URL is hosted on hostname and service is HTTPS, redirect to relative URL and not absolute.

       

      Most of F5 rewrite issues are caused because developers still insert full path instead of relative path when it is useless.

       

      And the redirect with 301 response code is a better solution than 302 (default with HTTP::redirect) to redirect permanently an URL to another.

       

      So, replace the line

       

      HTTP::redirect "https://www.pitneybowes.us/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"

      by

       

      HTTP::respond 301 noserver Location "/shop/ink-and-supplies/postage-meter-ink-supplies/for-dm-series/en-us/storeus"