Forum Discussion
greenasp_41938
Nimbostratus
Sep 08, 2009remove port number and redirect to https
I am trying to remove a port number and redirect to https:
Current Url: http://affiliates.abc.com:1003/affiliateimages/picture.gif
I need it to redirect to https://affilaites.abc.com/a...
hoolio
Cirrostratus
Sep 08, 2009Is there any hosts and/or URIs you want to serve on the port 1003 VS? If not, you could redirect every request to a hardcoded hostname and the original URI:
when HTTP_REQUEST {
Redirect client to hardcoded host and preserve the original URI
HTTP::redirect "https://affiliate.abc.com[HTTP::uri]"
}
Or if you only wanted to redirect requests where the host header value contains any port, you could use something like this:
when HTTP_REQUEST {
Check if Host contains a colon
if {[HTTP::host] contains ":"}{
Redirect client to hardcoded host and preserve the original URI
HTTP::redirect "https://affiliate.abc.com[HTTP::uri]"
}
}
Or if you want to redirect the client to the requested host without the port, you could use:
when HTTP_REQUEST {
Check if Host contains a colon
if {[HTTP::host] contains ":"}{
Redirect client to requested host minus the port and preserve the original URI
HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::uri]"
}
}
Hopefully that gives you a few ideas.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects