Forum Discussion
TheManu
Nimbostratus
Nov 12, 2007data gets lost when URL redirect
I want to implement a URL redirect for the following URL:
https://test.company.com/branch/workinggroup
Destination is:
https://test.company.com/programs/logic.php
The purpose of this page is that a user may post XML data, which is put into the body of the page. The PHP file contains the logic to read this data and automatically create an order in our system.
When I use the following URL redirection, the request is the redirected but the data gets lost:
when HTTP_REQUEST { if { [HTTP::host] eq "test.company.com/branch/workinggroup"}{ HTTP::header replace "host" "test.company.com/programs/logic.php"}}
Does anyone know how to change the iRule to keep the order process working?
Thanks for your help.
5 Replies
- hoolio
Cirrostratus
Hi,
The Host header value doesn't include the URI, so that rule should never get triggered to replace the Host header. Also, to be exact, you want to rewrite the host and URI--not send a 302 redirect. The redirect would result in the client sending a new GET request to the redirect location.
Can you try this?when HTTP_REQUEST { if { [HTTP::host] eq "test.company.com"}{ log local0. "Rewriting client request for host: [HTTP::header value Host], for URI: [HTTP::uri]" HTTP::header replace "host" "test.company.com" HTTP::uri "/programs/logic.php" } }
The log statement will be written to /var/log/ltm. You can watch the log using 'tail -f /var/log/ltm'.
Aaron - TheManu
Nimbostratus
Thank you for reply.
If i use this:when HTTP_REQUEST { if { [HTTP::host] eq "test.company.com"}{ log local0. "Rewriting client request for host: [HTTP::header value Host], for URI: [HTTP::uri]" HTTP::header replace "host" "test.company.com" HTTP::uri "/programs/logic.php" } }
the redirection will allways target the logic.php.
May I use it like this?when HTTP_REQUEST { if { [HTTP::host] eq "test.company.com/branch1/workinggroup"}{ log local0. "Rewriting client request for host: [HTTP::header value Host], for URI: [HTTP::uri]" HTTP::header replace "host" "test.company.com" HTTP::uri "/programs/logic1.php" } }when HTTP_REQUEST { if { [HTTP::host] eq "test.company.com/branch2/workinggroup"}{ log local0. "Rewriting client request for host: [HTTP::header value Host], for URI: [HTTP::uri]" HTTP::header replace "host" "test.company.com" HTTP::uri "/programs/logic2.php" } } - hoolio
Cirrostratus
Do you actually expect Host header values other than test.company.com? Assuming not, you could try this to verify the URI matches for the rewrite:when HTTP_REQUEST { check if the path of the request starts with "/branch1/workinggroup" if {[HTTP::path] starts_with "/branch1/workinggroup"}{ HTTP::header replace "Host" "test.company.com" HTTP::uri "/programs/logic1.php" check if the path of the request starts with "/branch2/workinggroup" } elseif }{[HTTP::path] starts_with "/branch2/workinggroup"}{ HTTP::header replace "Host" "test.company.com" HTTP::uri "/programs/logic2.php" } }
If you do want to validate the Host header equals "test.company.com" you could wrap the path checks in an 'if'.
Aaron - TheManu
Nimbostratus
Hi Aaron,
I can't use the Code you have just posted because I get an error:
01070151:3: Rule [iRule1] error:
line 1: [wrong args] [when HTTP_REQUEST ]
line 2: [undefined procedure: - TheManu
Nimbostratus
Me again,
i've found the error in my code...
...the problem was a line break which the system didn't like
Thank you very much...System is working now!!!
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