Forum Discussion
trying to redirect a url
I am trying to redirect a URL from site.domain.com to site.domain.com/subsite. I have the F5 configured for SSL off-loading so anything that come in is redirected from http to https. When a user goes to https://site.domain.com I want them to be redirected to https://site.domain.com/newsite. I tried different iRules but none of them seem to work. Has anyone done this before?
11 Replies
- DEJ_159363
Cirrus
Edited to include loop break/fix
Hello Jeff,
On VIP-80 you'll have the http -> https redirect. On VIP-443 you could use the one below. What issues are you running into?
RULE-x.x.x.x-443 when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.domain.com" and !([HTTP::uri] starts_with "/subsite") } { set respond value to 301 or 302 as preferred HTTP::respond 302 Location "https://site.domain.com/subsite" } }- DEJ_159363
Cirrus
One clarification. You are doing SSL off-loading by applying a client ssl profile on the 443 VIP, correct? - nitass
Employee
i think you also have to include (check) uri or path in the if-condition. otherwise, it is going to be loop because it redirects to the same fqdn. - DEJ_159363
Cirrus
Thank you for catching that N. Would the below break the redirect loop appropriately? when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.domain.com" and !([HTTP::uri] starts_with "/subsite")} { set respond value to 301 or 302 as preferred HTTP::respond 302 Location "https://site.domain.com/subsite" } }
- DEJ
Nimbostratus
Edited to include loop break/fix
Hello Jeff,
On VIP-80 you'll have the http -> https redirect. On VIP-443 you could use the one below. What issues are you running into?
RULE-x.x.x.x-443 when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.domain.com" and !([HTTP::uri] starts_with "/subsite") } { set respond value to 301 or 302 as preferred HTTP::respond 302 Location "https://site.domain.com/subsite" } }- DEJ
Nimbostratus
One clarification. You are doing SSL off-loading by applying a client ssl profile on the 443 VIP, correct? - nitass
Employee
i think you also have to include (check) uri or path in the if-condition. otherwise, it is going to be loop because it redirects to the same fqdn. - DEJ
Nimbostratus
Thank you for catching that N. Would the below break the redirect loop appropriately? when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "site.domain.com" and !([HTTP::uri] starts_with "/subsite")} { set respond value to 301 or 302 as preferred HTTP::respond 302 Location "https://site.domain.com/subsite" } }
- Sekhar
Nimbostratus
Hi Jeff, I think you are trying to redirect based on a uri
when HTTP_REQUEST { if { [HTTP::uri] == "/" } { HTTP::redirect "https://[HTTP::host]/newsite" } }Thanks, Sekhar
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com