Forum Discussion
Redirect website to new uri
I am completely new to F5 I've done a few simple redirects but having problems redirecting www.abc.dom to www.xyz.com/path/path2 for example
What I have in the iRule is:
if { [HTTP::request] contains "abc.com"}{ HTTP::respond 301 location "http://www.xyz.com/xxx/xxxxxxx[HTTP::uri]" }
This does not show an error but does not work.
Thanks for any help.
4 Replies
- nitass
Employee
This does not show an error but does not work.
have you tried http analyzer tool? it may be helpful.
HttpFox
https://addons.mozilla.org/en-US/firefox/addon/httpfox/ Depending on your software version you could do this several ways. You could use a HTTP Class in versions prior to 11.4, use Local Traffic Policies in 11.4 and newer, or use an iRule as you are attempting.
I would adjust your rule to the following:
if { [HTTP::host] ends_with "abc.com"} { HTTP::redirect "http://www.xyz.com/xxx/xxxxxxx[HTTP::uri]" }If you need a 301 redirect instead of a 302, you will have to use HTTP::respond.
You can get a better sense of what is happening by using a log statement like the following, putting it or something similar inside and outside of your if statement. Be sure to disable it before running the rule in production.
log local0. "client: [IP::client_addr], host: [HTTP::host], uri: [HTTP::uri]"- Kevin_Davies_40
Nacreous
HTTP::request is the wrong command for what you need. Use HTTP::host instead. However using an iRule for this is unnecessary.
Prior to 11.4 HTTP class rules will do this for you, no iRule required. I suggest you check them out. From 11.4 onwards HTTP policy will do this for you.
- nitass
Employee
good catch. :-)
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