Forum Discussion
Clonining HTTP URLs
Need help with creating an iRule that will clone URI to the new Host upon redirects.
Example:
All the pages under /city/gov/ directory in
www.boston.com/city/gov/
should map to
www.raleigh.com/city/gov/
Thanks, CP
5 Replies
- Nagesh_109273
Nimbostratus
Hi Chirag
you can try below i rule.
when HTTP_REQUEST { log local0. "Request: [HTTP::uri]" if { ( [HTTP::uri] starts_with "/city/gov/" ) } { log local0. "Request from client IP client_ip [IP::remote_addr] redirected to host: www.raleigh.com[HTTP::uri]" HTTP::redirect "www.raleigh.com[HTTP::uri]" } }
- Chirag_Patel_14
Nimbostratus
Hi Nagesh,
Thanks for your help. So, really the redirects are clones of URI from www.soundbite.com to www.genesys.com and this is iRule i used and subsequent error I received regarding the syntax but it seems fine to me.
when HTTP_REQUEST {
if { ([HTTP::host] equals "www.soundbite.com") and ( [HTTP::uri] starts_with "/education/" ) } { HTTP::respond 301 Location "www.genesys.com[HTTP::uri]" }
}
Error:
01070151:3: Rule [/Common/SB_To_Genesys_Clone_1] error: /Common/SB_To_Genesys_Clone_1:3: error: [missing a script after "if"][ ] /Common/SB_To_Genesys_Clone_1:4: error: [undefined procedure: HTTP::respond 301 Location "www.genesys.com[HTTP::uri]" ][{ HTTP::respond 301 Location "www.genesys.com[HTTP::uri]" } ]
- nitass
Employee
i do not get the error here.
config root@(ve11a)(cfg-sync In Sync)(Standby)(/Common)(tmos) list ltm rule qux ltm rule qux { when HTTP_REQUEST { if { ([HTTP::host] equals "www.soundbite.com") and ( [HTTP::uri] starts_with "/education/" ) } { HTTP::respond 301 Location "www.genesys.com[HTTP::uri]" } } } test [root@ve11a:Standby:In Sync] config curl -I http://172.28.24.10/education/something -H "Host: www.soundbite.com" HTTP/1.0 301 Moved Permanently Location: www.genesys.com/education/something Server: BigIP Connection: Keep-Alive Content-Length: 0 - Chirag_Patel_14
Nimbostratus
Hi Natass,
Thank you for your suggestion.
I applied following iRule and it worked:
when HTTP_REQUEST { if { ( [HTTP::uri] starts_with "/education" ) } { HTTP::respond 301 Location "www.genesys.com[HTTP::uri]" } }
On Big IP:
[cpatel@BIGIPASH5200-01:Active:Changes Pending] ~ curl -I http://172.16.2.235/education -H "Host: www.soundbite.com" HTTP/1.0 301 Moved Permanently Location: www.genesys.com/education Server: BigIP Connection: Keep-Alive Content-Length: 0
[cpatel@BIGIPASH5200-01:Active:Changes Pending] ~
HOWEVER,
When I enter the URL www.soundbite.com/education in a browser, it renders following 301 redirect: http://www.soundbite.com/www.genesys.com/education
So it takes in the www.genesys.com host part but does not get ride of SOundBite part!
Please advise.
- Chirag_Patel_14
Nimbostratus
This fixes it:
when HTTP_REQUEST { if { ([HTTP::host] equals "www.soundbite.com") and ( [HTTP::uri] starts_with "/education" ) } { HTTP::respond 301 Location "http://www.genesys.com[HTTP::uri]" } }
thanks, Chirag
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