Forum Discussion
Rewrite - is this efficient?
I'd like to catch both www.olddomain.com and olddomain .com, and rewrite to newdomain.com while keeping the URI present. This should serve as a wildcard catch-all to cover with and without the www.
www.olddomain.com/path/here.aspx to newdomain.com/path/here.aspx
This is what I came up with, simple enough?
iRule to intercept olddomain.com and www.olddomain .com
Rewrites domain name only, appends URI
when HTTP_REQUEST {
if { [HTTP::host] contains "olddomain" } {
HTTP::redirect "http://newdomain.com[HTTP::uri]"
}
}
4 Replies
- nitass
Employee
what about httpclass?[root@ve1023:Active] config b virtual bar list virtual bar { destination 172.28.19.79:80 ip protocol 6 httpclass myhttpclass profiles { http {} tcp {} } } [root@ve1023:Active] config b profile myhttpclass list profile httpclass myhttpclass { defaults from httpclass pool none redirect "http://newdomain.com[HTTP::uri]" hosts { "olddomain.com" "www.olddomain.com" } } [root@ve1023:Active] config curl -I http://olddomain.com/something HTTP/1.0 302 Found Location: http://newdomain.com/something Connection: Keep-Alive Content-Length: 0 [root@ve1023:Active] config curl -I http://www.olddomain.com/something HTTP/1.0 302 Found Location: http://newdomain.com/something Connection: Keep-Alive Content-Length: 0 - Joe_Pipitone
Nimbostratus
Interesting....I will see how this one works - Thank you very much for your help. Is using an httpclass going to be more efficient than the if statement above? I'll let you know how it worksEDIT: Works great! However I have another iRule that matches a custom URI and redirects only if client traffic goes to:
http://newdomain.com/productinfo and http://newdomain.com/productinfo/
I wonder if this will trigger and log the error "too many redirects"
I will experiment.
- nitass
Employee
Is using an httpclass going to be more efficient than the if statement above?it is just my thought.
anyway, there is past discussion topic about this.
iRule vs HttpClass
https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/1182490/showtab/groupforums/Default.aspx - Joe_Pipitone
Nimbostratus
Thank you, everything is working great with your httpclass.
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