Forum Discussion

3 Replies

  • Thoughts on if this iRule would meet the above needs and perform the correct 301 redirect?

    when HTTP_REQUEST {
    switch [string tolower [HTTP::host]] {
    "some.example.com" {
    if { [HTTP::uri] starts_with "/content"}{
    set uri [HTTP::uri [string map {"/content" ""} [HTTP::uri]]]
    HTTP::respond 301 Location "https://another.example.com$uri"
    }
    default {HTTP::respond 301 Location "https://another.example.com[HTTP::uri]"}
    }
    

    }

  • The content of the iRules is perfect. I just formatted the iRule a bit and added a missing closing bracked.

    See the formated output below:

    when HTTP_REQUEST {
      switch [string tolower [HTTP::host]] {
        "some.example.com" {
          if { [HTTP::uri] starts_with "/content"}{
            set uri [HTTP::uri [string map {"/content" ""} [HTTP::uri]]]
            HTTP::respond 301 Location "https://another.example.com$uri"
          }
        }
        default {HTTP::respond 301 Location "https://another.example.com[HTTP::uri]"}
      }
    }