Forum Discussion
URI substitution
This is what I wrote
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/csn/CI/" } {
set NCI [HTTP::header "FILTER"]
log local0. "$NCI"
HTTP::uri [string map {/csn/CI/ /csn/"$NCI"/} [HTTP::uri]]
log local0. [string map {/csn/CI/ /csn/"$NCI"/} [HTTP::path]]
HTTP::path [string map -nocase {/csn/CI/ /csn/"$NCI"/} [HTTP::path]]
}
}
Problem is that the url https://xyz.com/csn/CI/value1/generic.html is being re-written to https://xyz.com/csn/"$NCI"/value1/generic.html
I want it to be https://xyz.com/csn/IBMCORP/value1/generic.html
So the value for $NCI is not being substituted. However for log.local0. "NCI" actually prints out the right value = IBMCORP
9 Replies
- hoolio
Cirrostratus
Hi, - doc_hack_12696
Nimbostratus
Just tried it. It works! Thank you - greeblesnort
Nimbostratus
sorry to revive an old thread, but this is very similar to my current issue. I'm trying to rewrite an incoming request thusly:
Log output is:when HTTP_REQUEST {set OLDPATH [HTTP::path]log local0.info "got request for $OLDPATH"if {[HTTP::path] starts_with "/dealers"} {HTTP::path [string map -nocase "/dealers/ /used_car_classifieds/dealer/" [HTTP::path]]set NEWPATH [HTTP::path]log local0. "$OLDPATH should've been rewritten to $NEWPATH"}}
- hoolio
Cirrostratus
The results for these HTTP:: commands are cached in the same event and event priority:when HTTP_REQUEST priority 501 { This event runs after the HTTP_REQUEST event with a default priority of 500 log local0. "Updated \[HTTP::path\]: [HTTP::path]" }
- greeblesnort
Nimbostratus
Running 10.2.3 build 123.0 HF1, so yes, we're still on 10.Regarding priority, I turned up logging trying to troubleshoot this and see this in the logs:
Jan 20 15:12:22 local/tmm debug tmm[5350]: 01220003:7: Virtual dvlp_cfx_vs - Updated rule dvlp_dealer_rewrite when priority 32768000
Is this a different priority or do we have a setting out of wack somewhere? I know I've read that, by default, iRules are priority 500(?), and I don't recall changing it, but this setup is only about 2 weeks old, so we're still in the "getting comfortable with it" phase.
- greeblesnort
Nimbostratus
Running 10.2.3 build 123.0 HF1, so yes, we're still on 10.Regarding priority, I turned up logging trying to troubleshoot this and see this in the logs:
Jan 20 15:12:22 local/tmm debug tmm[5350]: 01220003:7: Virtual dvlp_cfx_vs - Updated rule dvlp_dealer_rewrite when priority 32768000
Is this a different priority or do we have a setting out of wack somewhere? I know I've read that, by default, iRules are priority 500(?), and I don't recall changing it, but this setup is only about 2 weeks old, so we're still in the "getting comfortable with it" phase.
- greeblesnort
Nimbostratus
Running 10.2.3 build 123.0 HF1, so yes, we're still on 10.Regarding priority, I turned up logging trying to troubleshoot this and see this in the logs:
Jan 20 15:12:22 local/tmm debug tmm[5350]: 01220003:7: Virtual dvlp_cfx_vs - Updated rule dvlp_dealer_rewrite when priority 32768000
Is this a different priority or do we have a setting out of wack somewhere? I know I've read that, by default, iRules are priority 500, and I don't recall changing it, but this setup is only about 2 weeks old, so we're still in the "getting comfortable with it" phase.
- greeblesnort
Nimbostratus
woops, double post
- hoolio
Cirrostratus
If you don't specify the priority for an iRule or iRule event it defaults to 500. For your HTTP::path rewrite to work, you don't need to set a custom priority. The rewrite should be working fine as it is. To see the change logged you could add the debug event with a higher priority.
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