Forum Discussion

Steven_Fulton_1's avatar
Steven_Fulton_1
Icon for Nimbostratus rankNimbostratus
Feb 23, 2015
Solved

How to set up http 301 response

Here is my problem. Our web server administrator has a website:   which is currently hosted by a vendor they will no longer use once the site is retired.   He is going to make a new site call...
  • shaggy_121467's avatar
    Feb 23, 2015

    once you create a new virtual server for siteA, assign an iRule like:

    when HTTP_REQUEST {
      HTTP::respond 301 Location "http://siteB.company.com"
    }
    

    you could also do the same redirect using the same virtual server that you are using for siteB, assuming it's not HTTPS (certificate SANs would need to include siteA.company.com to avoid browser trust error), but the iRule would be:

    when HTTP_REQUEST {
      if {[string tolower [HTTP::host]] equals "sitea.company.com"}{
        HTTP::respond 301 Location "http://siteB.company.com"
      }
    }
    

    if the URI structure is going to be the same between the two sites, I recommend tacking on [HTTP::uri] to the redirect so users don't have to re-navigate to the URL they originally requested:

    HTTP::respond 301 Location "http://siteB.company.com[HTTP::uri]"