Forum Discussion

kazeem_yusuf1's avatar
kazeem_yusuf1
Icon for Nimbostratus rankNimbostratus
Jan 19, 2017

IRULE WHICH EXTENDS AN HTTPS HEADER TO ANOTHER HTTPS HEADER (AVOIDING INFINITE REDIRECTION LOOPS))

Hello, I have been requested to create an irule which redirects in the following format. https://kazeem.networkershome.com to https://kazeem.networkershome.com/ux/kazeemapp.

I implemented an irule on the Virtual HTTPS header but was getting an infinite redirection loop.

when HTTP_REQUEST { 
    if { [HTTP::host] equals "kazeem.networkershome.com" } {
        HTTP::redirect "
    } else { 
        HTTP::redirect "https://[HTTP::host][HTTP::uri]" 
    }
}

2 Replies

  • try this:

     

    when HTTP_REQUEST {
        if { [HTTP::host] equals "kazeem.networkershome.com" &&  [HTTP::uri] equals "/"} {
            HTTP::redirect "https://kazeem.networkershome.com/ux/smart-it";
        }
    }
    

     

  • Just an FYI - the code above will perform an 302 (Conditional) redirect. A 301 (permanent) redirect is more appropriate in this situation, and will increase SEO rankings.

     

    HTTP::respond 301 noserver Location "https://kazeem.networkershome.com/ux/smart-it"

     

    If you don't want browsers to cache it you can add a Cache-Control directive;

     

    HTTP::respond 301 noserver Location "https://kazeem.networkershome.com/ux/smart-it" Cache-Control "max-age=7200"