Forum Discussion

James_Hamoline_'s avatar
James_Hamoline_
Icon for Nimbostratus rankNimbostratus
Sep 20, 2005

301 Redirection via iRule

I currently have an iRule that redirects users. However, HTTP:redirect does a temporary redirect (HTTP Status Code 302). I want a permanent redirect (HTTP Status Code 301).

 

 

Here is the iRule:

 

 

when HTTP_REQUEST {

 

HTTP::redirect "http://www.[HTTP::host][HTTP::uri]"

 

}

 

 

Basically, when this iRule runs it tacks on the www.

 

 

Does anybody know how I can get this iRule to do a 301 Permanent Redirect?
  • You could use the "HTTP::respond" command to send any HTTP response code you want back to the client.

     

     

    Usage:

     

    HTTP::respond [content ]

     

     

    Give this a try:

     

     

    when HTTP_REQUEST {
      HTTP::respond 301 "Location" "http://www.[HTTP::host][HTTP::uri]"
    }

     

     

    -Joe
  • Thanks,

     

     

    That works perfectly. Is there a document that explains the Syntax, commands and object that can be used for iRules?
  • The documentation currently exists in the BIG-IP Product Documentation. Check out "Configuration Guide for Local Traffic Management (updated 7/25/2005)" on ask.f5.com for documentation on iRules syntax.

     

     

    -Joe