Forum Discussion
.com. doesn't redirect but .com does
Hello Everyone,
Quick question regarding a re-direct irule. so we have a requirement to redirect example.com and exampleabc.com to examplexyz.com and this works via the following irule but if append a dot after .com then it doesn't redirect... so example.com. doesn't redirect. we also need it to be a 301 re-direct also we can not use generic host as this is a shared VIP. Any thoughts?
when HTTP_REQUEST { set r_host [HTTP::header "Host"] switch $r_host { "; - "; -
HTTP::respond 301 "Location" "https://www.examplexyz.com"
}
} }
- Abhash_way_1901
Nimbostratus
when HTTP_REQUEST { set r_host [HTTP::header "Host"]
switch $r_host { ";; - ";; - HTTP::respond 301 "Location" "; }
} }
- Stanislas_Piro2
Cumulonimbus
Hi,
switch command evaluate exact value.
us not the same string thanexample.com
example.com.
when HTTP_REQUEST { switch -- [HTTP::host] { "www.example.com" - "www.example.com." - "www.exampleabc.com" - "www.exampleabc.com." { HTTP::respond 301 "Location" "https://www.examplexyz.com" } } }
you can also use glob option to use wildcard
when HTTP_REQUEST { switch -glob -- [HTTP::host] { "www.example.com?" - "www.exampleabc.com?" { HTTP::respond 301 "Location" "https://www.examplexyz.com" } } }
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