Forum Discussion
irule based om http request.
Hi,
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "abc-test-domain.com" } {
HTTP::respond 301 "Location" "http://dc-abc-test-domain1.com"
}
}
- Abhijith_SubbanMar 19, 2018Nimbostratus
If, the listening and responding port is 8080 then during http response header. Can this be done :
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "abc-test-domain.com" } { HTTP::respond 301 "Location" "[http://dc-test-domain1.com:8080 :8080"](http://dc-test-domain1.com:8080 :8080); } }
- oguzyMar 19, 2018Cirrostratus
Yes, sure.
- THiMar 19, 2018Nimbostratus
Just a note on the 301 redirect:
Instead of 301 Moved Permanently, I'd rather use 307 Temporary Redirect. Browsers may cache 301s indefinitely, and it may be difficult to remove the cache entry, if you need to modify the redirect location later on. Depending on browser, the 301 cache may persist over restarts..
Some may use 302 redirects, but 307 will also keep the original HTTP method (eg. GET, POST, HEAD), 302 may not.
So, I would try to avoid a 301 redirects, unless I were 100% sure of the need of permanently de-commissioning the old URL.
- oguzyMar 19, 2018Cirrostratus
Hi Timo,
Thank you for your informational note and contribution.
- Abhijith_SubbanMar 19, 2018Nimbostratus
Thanks a lot guys, just to add. This is my actual requirement and want to make sure it is fine :
abc-test-domain.com:8080 -> dc-test-domain1.com:8080
abc-test-domain.com:4443 -> dc-test-domain1.com:4443
So will this irule work :
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "abc-test-domain.com" } { HTTP::respond 307 "Location" "; else if HTTP::respond 307 "Location" "; } }
- oguzyMar 19, 2018Cirrostratus
Hi again,
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "abc-test-domain.com" } { HTTP::respond 307 "Location" "http://dc-test-domain1.com:8080" } else { HTTP::respond 307 "Location" "http://dc-test-domain1.com:4443" } }
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