I have a very simple redirect I want to create but can’t seem to get my syntax correct.
All I want to do is redirect Http://website1 to http://website2
How do I do this with a simple iRule?
We are running BIG-IP 11.30 HF3
I have a very simple redirect I want to create but can’t seem to get my syntax correct.
All I want to do is redirect Http://website1 to http://website2
How do I do this with a simple iRule?
We are running BIG-IP 11.30 HF3
Please try this:
when HTTP_REQUEST {
HTTP::redirect "http://www.example.com"
}
Applying this iRule to a virtual server will cause ALL requests to be immediately redirected to the second host. This also assumes the two URLs are not hosted on the same virtual server.
I’m confused, how will that redirect website1 to website2? This is what I have and it doesn’t work:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals “http://website1” } { HTTP::redirect “http://website2” } }
There is a mistake : HTTP:host is the host without the scheme.
http://website1 --> host = website1
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "website1" } { HTTP::redirect "http://website2" } }
THANK YOU! That worked!
Oh but wait, I have a virtual directory underneanth website1/app1 that I don’t want redirected. How do I do that?
Check [HTTP:uri] as well. HTTP:host == website1 && HTTP:uri != app1
I feel so stupid, but will that redirect app1 also? Here is my scenerio, I only need the main site of website1 redirected. Like this:
http://website1 = redirect to website2 http://website1/app1 - do not redirect http://website1/app2 - do not redirect etc… Can you tell me exactly what that rule would look like? Thanks!
No problem Debbie.
when HTTP_REQUEST
{
if { [string tolower [HTTP::host]] equals "website1" && not ([string tolower [HTTP::uri]] starts_with "/app")}
{
HTTP::redirect "http://website2"
}
}
I’m getting the following error when I try to save this rule:
01070151:3: Rule [/Common/WisconsinFastForwardRedirect] error: line 1: [wrong args] [when HTTP_REQUEST ] line 2: [undefined procedure: if { [string tolower [HTTP::host]] equals “website1” && not ([string tolower [HTTP::uri]] starts_with “/app”)} { HTTP::redirect “http://website2” } ] [{ if { [string tolower [HTTP::host]] equals “website1” && not ([string tolower [HTTP::uri]] starts_with “/app”)} { HTTP::redirect “http://website2” } }]
Try putting the opening brace on the same line as ‘when HTTP_REQUEST’, and make sure that you have the right number of closing braces.
Copy / paste issue from Devcentral.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "website1" && not ([string tolower [HTTP::uri]] starts_with "/app")} { HTTP::redirect "http://website2" } }
Copy and paste this line ![]()
Thank you for your help but it’s not quite working. My website1 is being redirected but when I go to http://website1/app1 “Internet Explorer cannot display the webpage”
Humm, try this
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "website1" && not ([string tolower [HTTP::uri]] starts_with "/app")} { HTTP::redirect "http://website2" } else { return } }
But be careful. All objects in /app must stay in /app in your website. Else objects will be redirected to website2.
Same thing, main redirect works but not the /app. I need to leave for the day. If I don’t get this figured out tomorrow, I’ll send you another message. Thanks again for your help today. As you can see, I’m not very familiar with iRules but someone else in my are is and they were out today so I was trying to get this working without them.