Forum Discussion
need help creating an iRule
hi all, Hope you all doing well. Could someone help me with creating an iRule? I would like to create an iRule which will forward all http/https request to go to a URL.
For example: abc.com www.abc.com http://abc.com etcc. will all go to https://www.abc.com
Here's the current iRule i have but it's re-directing all traffic to https://abc.com . I need it all to go to https://www.abc.com instead.
when HTTP_REQUEST {
Check if the host starts with www. if {[string tolower [HTTP::host]] starts_with "www."}{
Redirect with the www. prefix removed to the same URI
HTTP::redirect "https://[string range [HTTP::host] 4 end][HTTP::uri]"
} }
Thank you very much for your assistance, JT
- JGTRAN_142005Nimbostratus
when HTTP_REQUEST {
Check if the host starts with www.
if {[string tolower [HTTP::host]] starts_with "www."}{
Redirect with the www. prefix removed to the same URI HTTP::redirect "https://[string range [HTTP::host] 4 end][HTTP::uri]"
} }
- JGTRAN_142005Nimbostratus
hi all, i found the answer after searching the forum.
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "example.com" }{ HTTP::respond 301 Location "http://www.[HTTP::host][HTTP::uri]" } }
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