Forum Discussion
HTTP Redirect not working
I am new to iRules and I am trying to setup an iRule to redirect some traffic. I want to do this when status 301 and 302 are returned in the headers, but for basic testing I went with just the below iRule. I can't seem to get the redirect to work let alone try to incorporate the 301 and 302. Any advice is greatly appreciated
when HTTP_REQUEST { if {([HTTP::host] equals ";) } { HTTP::redirect "; } }
- Stanislas_Piro2
Cumulonimbus
[HTTP::host] May return abc.domain.com and not http://abc.domain.com
You will need an iRule something like this:
when HTTP_REQUEST {
- Stanislas_Piro2
Cumulonimbus
when you request URL http://www.domain123.com/.well-known/acme-challenge/aeIswOdWkV3TlYv24PI7Nv9OYvcF0eKfyrLlVpdSW7s, the HTTP request is:
GET /.well-known/acme-challenge/aeIswOdWkV3TlYv24PI7Nv9OYvcF0eKfyrLlVpdSW7s HTTP/1.1 Host: www.domain123.com User-Agent: Mozilla/4.0......
So following HTTP commands return:
- HTTP::host -->
- HTTP::uri --> /.well-known/acme-challenge/aeIswOdWkV3TlYv24PI7Nv9OYvcF0eKfyrLlVpdSW7s
So the irule must be:
when HTTP_REQUEST { if {([HTTP::host] equals "www.domain123.com") } { HTTP::redirect "http://www.somethingelse.com[HTTP::uri]" } }
or if you want to manage URI in condition:
when HTTP_REQUEST { if {([HTTP::host] equals "www.domain123.com") && [HTTP::uri] starts_with "/.well-known/acme-challenge/"} { HTTP::redirect "http://www.somethingelse.com[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