Forum Discussion
Mohammed_Akram
Altostratus
7 years agorequest needs to redirect from https://www.example.com to https://example.com/xyz
I needs to redirect the URL if a user enters https://www.example.com it should redirect to https://example.com/xyz , I have http to https irule applied on 80.
The_Y
Cirrus
7 years agoMohamed,
if you are looking for a static redirect then this should work
when HTTP_REQUEST {
if {[string tolower [HTTP::host]] ends_with "example.com"} {
HTTP::redirect "https://example.com/xyz"
}
}- Hamish7 years ago
Cirrocumulus
If www.example.com and example.com are the same VS, then this is the source of your looped redirect. You hit the same host again (example.com) and then redirect because your HOST ends with example.com...
You need to check the the URI is NOT /xyz already...
e.g
when HTTP_REQUEST { if { ([HTTP::uri] begins_with "/xyz") } { return } if {[string tolower [HTTP::host]] ends_with "example.com" } { HTTP::redirect "https://example.com/xyz" } }Change begins_with to equals depending on what the rest of the content looks like...
- Mohammed_Akram7 years ago
Altostratus
Error in Irule
- Hamish7 years ago
Cirrocumulus
Because I was typing on the fly. It's starts_with not begins_with
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects