Forum Discussion
Need some help with iRule for URI redirection.
I have an irule that uses a string-data-group to list the old URIs and new URIs to which it should be redirected to. Here are the details:
ltm data-group internal redir_dgl { records { / { data https://abcnew.example.com } /abcold/uri1 { data https://abcnew.example.com/uri1 } /abcold/uri2 { data https://abcnew.example.com/uri2 } /abcold/uri1/uri3 { data https://abcnew.example.com/uri1 } } type string }
when HTTP_REQUEST { set REDIRECT [class match -value [string tolower [HTTP:uri]]equal redir_dgl] if { $REDIRECT ne "" } { HTTP::respond 301 Location "$REDIRECT" } else { pool $POOL_DEFAULT } }
This is just a sample. Now in this setup I observe that few redirection do not take effect, and rather I get 404 error. What can be the possible issue?
- Kevin_Stewart
Employee
Might I suggest you insert some logging:
when HTTP_REQUEST { set REDIRECT [class match -value [string tolower [HTTP:uri]]equal redir_dgl] log local0. "REDIRECT = $REDIRECT" if { $REDIRECT ne "" } { log local0. "redirecting to $REDIRECT" HTTP::respond 301 Location "$REDIRECT" } else { log local0. "sending to default pool" pool $POOL_DEFAULT } }
You may be surprised by some of the URLs your getting.
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