Forum Discussion
Can't get my redirect to work !!!
Hi All,
I'm trying to get my redirect to work and I'm have some problems, can some one put me right please.
when HTTP_REQUEST {
if { [HTTP::uri] equals "https://test.geowessex.com" } {
HTTP::redirect "https://test.geowessex.com/geoserver/"}
elseif { [HTTP::uri] equals "https://test2.geowessex.com" } {
HTTP::redirect "https://vmcrgifme1"}
}
27 Replies
Hi Paul!
You're comparing against the full url whereas the uri is the part after the host.
Try this:
when HTTP_REQUEST { set host [string tolower [HTTP::host]] if { $host equals "test.geowessex.com" } { HTTP::redirect "https://test.geowessex.com/geoserver/"} elseif { $host equals "test2.geowessex.com" } { HTTP::redirect "https://vmcrgifme1" } }Hope that answers your question. 🙂
/Patrik
- paul_dcc
Nimbostratus
Hi Patrik,
Just to give you some background, this irule is for a F5 ASM box. This irule does not work at all, before I had an irule that worked fine (see below)
when HTTP_REQUEST { if { [HTTP::host] equals "https://test.geowessex.com" } { HTTP::redirect "https://test.geowessex.com/geoserver/"} }
but with your irule I can't get it to work at all.
I hope you can help.
Hi Paul
Strange.
Try this rule instead?
when HTTP_REQUEST { set host [string tolower [HTTP::host]] if { $host equals "https://test.geowessex.com" } { HTTP::redirect "https://test.geowessex.com/geoserver/"} elseif { $host equals "https://test2.geowessex.com" } { HTTP::redirect "https://vmcrgifme1" } }If that does not work, try adding log section to see what the hosts header contains.
when HTTP_REQUEST { set host [string tolower [HTTP::host]] log local0. $host if { $host equals "https://test.geowessex.com" } { HTTP::redirect "https://test.geowessex.com/geoserver/"} elseif { $host equals "https://test2.geowessex.com" } { HTTP::redirect "https://vmcrgifme1" } }Then check the result in the /var/log/ltm log.
/Patrik
- paul_dcc
Nimbostratus
Hi Patrik,
The first redirect works (https://test.geowessex.com) but it ever does the second one https://test2.geowessex.com, I don't no what is going wrong ?
- paul_dcc
Nimbostratus
Tue Jun 24 12:34:29 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:29 BST 2014 info asm1 tmm1[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm1[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm1[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com
Hi Paul!
Tue Jun 24 12:34:29 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:29 BST 2014 info asm1 tmm1[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm1[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.com Tue Jun 24 12:34:30 BST 2014 info asm1 tmm1[11765] Rule /Common/New-Geowessex-Redirect : test.geowessex.comLooking at your log you never use test2.geowessex.com and that's why the second redirect never fires.
/Patrik
- paul_dcc
Nimbostratus
Hi Patrik,
But I was ? so i'm even more confused
Maybe you don't reach the LTM when using test2.geowessex.com? Check the dns and the hosts file on your client?
/Patrik
- paul_dcc
Nimbostratus
Hi Patrik,
I can see what is happening now, ASM does not seem to be hitting the irule at all. I need to take off the security policy next and see weather that make a difference.
- Sounds like a plan! :)
- Arie
Altostratus
@Patrik: You've re-introduced the protocol (https) in the comparison. However, HTTP::host contains the host only.
when HTTP_REQUEST { set host [string tolower [HTTP::host]] if { $host equals "test.geowessex.com" } { HTTP::redirect "https://test.geowessex.com/geoserver/"} elseif { $host equals "test2.geowessex.com" } { HTTP::redirect "https://vmcrgifme1" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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