Forum Discussion
Need an iRule to append domain.com on an HTTPS request
I have an iRule set up to check my http requests
when HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { *.domain.com { HTTP::redirect https://[HTTP::host][HTTP::uri] } default { HTTP::redirect https://[HTTP::host].domain.com[HTTP::uri] } } }
This is working great for http requests. So if someone enters any of the following in the browser it sends them to https://website.domain.com http://website.domain.com https://website.domain.com
The problem I have is if someone enters they get an error. I need to add the .domain.com on the end so it goes to https://website.domain.com.
Any ideas? I need this to be generic so it adds the .domain.com for any host (not just a specific website) as I will need to use this iRule for potentially dozens of sites.
1 Reply
- Michael_Jenkins
Cirrostratus
Are the requests coming from the internet or the intranet? The problem I would see with this idea from the internet is that you have to have a fully qualified domain to being with (e.g. example.com) so you'd be trying to redirect to
which I'm guessing isn't what you want. So that would probably not work right.example.com.domain.comInternally, if you're just trying to redirect from a simple hostname to a fully qualified hostname (e.g.
tohttps://example
), you would need to create a new iRule a little different than your current one and then attach it to your HTTPS vip. something like this probably.https://example.domain.comwhen HTTP_REQUEST { switch -glob [string tolower [HTTP::host]] { *.domain.com { Do nothing } default { HTTP::redirect https://[HTTP::host].domain.com[HTTP::uri] } } }
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