Forum Discussion

Carol_Williams_'s avatar
Carol_Williams_
Icon for Nimbostratus rankNimbostratus
Jun 13, 2006

Send a 301 error instead of 302 with redirect

I am using version 4.6.4 and currently have a rule to direct everything coming in without a www to www.sitename.com. I would like to tell F5 to make this a permanently moved(301 error) instead of a temporary moved(302 error). Is there a way to do this with irules?

 

 

Here is the Rule:

 

 

if (http_host == "mysite.com") {

 

redirect to "www.mysite.com/%u"

 

}

 

else {

 

use pool mypool

 

}

 

 

 

Thanks

 

Carol

4 Replies

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hi Carol -

     

     

    I know you can use HTTP::respond in v9 to send a 301, but I'm pretty sure there is no way to send anything but the default redirect in v4.

     

     

    /deb
  • I have a customer request of which I'm unsure whether it can be done at all or not: I have a URL where it is redirect from http to https . issue: There Application team asking why TES application has 302 redirection instead 301. What would be the impact to change 302 to 301. What are the requirement if we need to redirect to 301

     

     

    Can u pls advice me for the above task
  • What version of code are you using? If you are using v9 or newer you can do something like this:

     

     

    
    when HTTP_REQUEST {
      HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]
    }
    

     

     

    301 redirects are to inform search engines that the page has moved permanently. It shouldn't have any huge impact one way or the other(302 or 301) for this.

     

     

    Eric