kevinmc
Jun 30, 2017Altocumulus
URL rewrite
I am trying to rewrite a URL for users who are using an old URL.
So if the user enters
sharepoint.abc.net
I want to redirect them to
home.sharepoint.abc.net
I have tried an irule as below ...
Hi kevinmc,
first you need to be clear about the wording rewrite and redirect.
Redirect: Sending the client a 301/302 response with the new correct URL. The client will then send a new request towards the new URL.
Rewrite: F5 takes the URL from the client, changes the URL (hostname and/or URI) and forward the request with this new URL towards the real server. Means the client still sees the "old" URL in its browser bar, but the real server sees the new URL.
So you are talking about a redirect and this can be handled with the following iRule:
when HTTP_REQUEST {
if {[string tolower [HTTP::Host]] starts_with "sharepoint.abc.net"} {
For a 301 redirect us this line
HTTP::respond 301 location "http(s)://home.sharepoint.hscni.net[HTTP::uri]"
For a 302 redirect us this line
HTTP::redirect "http(s)://home.sharepoint.hscni.net[HTTP::uri]"
}
}
Hope that's clear now.
Ciao Stefan 🙂