Forum Discussion

Tyson_James's avatar
Jul 18, 2024

Redirect iRule differences...

We have a situation where we need to redirect users from one domain to another and had been using Method 1 ( shown below ) of redirection via iRule.  It was recently brought to our attention by our web team that the way we were doing the redirects for one of their sites in particular was "really bad" for SEO and we ended up making them happy with doing it via Method 2 ( shown below ). While my team officially maintains our BIG-IP's, we are not network/web savvy and don't really understand the difference here.  We have a new site that needs to be redirected and we are not sure which method to use.  Would someone please explain in what cases you would use one over the other.  Thanks.  

Method 1

when HTTP_REQUEST {
  if { [HTTP::host] eq "website1.com" } {
    HTTP::redirect https://websitesite2.com
  }
}

Method 2

when HTTP_REQUEST {
  if { ([string tolower [HTTP::host]] eq "website1.com")} {
       HTTP::respond 301 Location "http://website2.com"
       return
   }
}

 

1 Reply

  • I wasn't aware of how this caused issues for SEO but the following article seems to explain it a bit.

    https://www.incrementors.com/blog/why-302-redirect-can-hurt-your-website-and-seo-efforts/

    Now from a technical standpoint, the biggest difference between "HTTP::redirect" and "HTTP::respond" is that redirect is always an HTTP 302 where as a respond allows you to respond with a specific HTTP status code, in this instance you are responding with a 301. If additional changes to the redirect are coming soon then you might opt for an "HTTP::redirect" and then when it's permanent you can configure "HTTP::respond 301". If you plan on making this switch you might consider using "HTTP::respond 302" and then changing it to "301" later so that the majority of the syntax remains the same.