Forum Discussion

yogpog_205998's avatar
yogpog_205998
Icon for Nimbostratus rankNimbostratus
Jul 29, 2015

301 redirection irule

Dear Team,

 

Currently under Port 80 below irule is configured

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/" { HTTP::redirect "https://[HTTP::host]/XXX.aspx" } } }

 

Now the requirement is url redirection from 302 to 301

 

How this can be achieved.

 

2 Replies

  • Try this:

    when HTTP_REQUEST { 
        if { [HTTP::uri] equals "/" } { 
            HTTP::respond 301 Location "https://[HTTP::host]/XXX.aspx" 
        } 
    }
    

    You don't really benefit from a switch if you're only evaluating one thing, and there's no need to do [string tolower ] if you're just checking for "/".

  • I'm not sure I understand what you're asking. The iRule will force a "301 Moved Permanently" redirect. You're not going to see a 302.