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]"
}
}
- nitassEmployeewhat 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_PipitoneNimbostratusInteresting....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 works
EDIT: 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.
- nitassEmployeeIs using an httpclass going to be more efficient than the if statement above?it is just my thought.
- Joe_PipitoneNimbostratusThank you, everything is working great with your httpclass.
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