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/affiliateimages/picture.gif (picture.gif is a changing variable)
I setup a vs for vs_affiliate_redirect_1003 assigned to port 1003;
However, I can't get the irule to work.(I am sure I am not setting it up right)
when HTTP_REQUEST { if { [HTTP::host] eq "affiliate.abc.com:1003"} {
HTTP::redirect "https://affiliate.abc.com"
}
}
2 Replies
- The_Bhattman
Nimbostratus
Hi,
Since you have a VS for port 1003 created I am assuming you have one set up for 443 so apply the following on vs_affiliate_redirect_1003when HTTP_REQUEST { if {[HTTP::host] eq "affiliate.abc.com" { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
Basically it will redirect to vs_affiliate_443 w/o the port information.
I hope this helps
CB - hoolio
Cirrostratus
Is 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