Need iRule for 301 redirection
I would like to ask expert assistance creating an iRule on the LTM to perform a 301 redirection. The following is required:
-
If requested URL contains hostname example.edu (not case sensitive) a. 301 redirect user to http://www.example.edu, and include all additional pathing. Examples: i. Example 1: I. Original request: http://example.edu/example a. Must 301 redirect to: http://www.example.edu/example ii. Example 2: II. Original request: http://example.edu/example/?user=1 a. Must 301 redirect to http://www.example.edu/example/?user=1
-
If requested URL contains hostname new.example.edu (not case sensitive) a. 301 redirect user to http://www.example.edu, and include all additional pathing. Examples: i. Example 1: I. Original request: http://new.example.edu/example a. Must 301 redirect to: http://www.example.edu/example ii. Example 2: II. Original request: http://new.example.edu/example/?user=1 a. Must 301 redirect to http://www.example.edu/example/?user=1
I created the following iRule, however, it seems to only have taken care of the first redirection request and not any of the others: when HTTP_REQUEST { if {[HTTP::host] equals "example.edu"} { HTTP::respond 301 "Location" "http://www.example.edu" } if {[HTTP::host] equals "http://example.edu[HTTP::uri]"} { HTTP::respond 301 "Location" "http://www.example.edu[HTTP::uri]" } if {[HTTP::host] equals "new.example.edu"} { HTTP::respond 301 "Location" "http://www.example.edu" } if {[HTTP::host] equals "http://new.example.edu[HTTP::uri]"} { HTTP::respond 301 "Location" "http://www.example.edu[HTTP::uri]" } }