Forum Discussion
iRule for HTTPS Virtual Server
Hi,
I have a virtual server created at port 443. I want the URL to be permanently redirected as per below: From HTTPS://XYZ.com to HTTPS://XYZ.com/alpha
I think an iRule should solve my purpose but can iRule be implemented on HTTPS VS. Something like below: when HTTP_REQUEST { HTTP::redirect "https://[HTTP::host][HTTP::uri]" }
Can someone please help me on this.
7 Replies
Try this one?
when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] if { $uri eq "/" } { HTTP::respond 301 Location "https://xyz.com/alpha" } }/Patrik
- Tanuj_90312
Nimbostratus
Thank for your reply Patrik, but this would only work on a HTTP VS I suppose. Is there any sytax for HTTPS VS like HTTPS_REQUEST as my VS is on initial port 443?
As long as you have an HTTP and SSL client profile on the VS the iRule syntax does not change, if that's what you mean?
/Patrik
- Tanuj_90312
Nimbostratus
Ok Got you Patrik, Will check the same and get back to you if found anything interesting with this. Thanks!
- Tanuj_90312
Nimbostratus
This worked like a charm for me. Thanks!
Just one more thing I wanted to know, in case there is one particular URL that I want to be redirected to same URL itself. For more clarity, I want HTTPS://XYZ.com to be redirected to HTTPS://XYZ.com/alpha but HTTPS://XYZ.com/beta URL specifically not to be redirected and should open as HTTPS://XYZ.com/beta itself. For now with the current rule HTTPS://XYZ.com/beta is being redirected to HTTPS://XYZ.com/beta/alpha. Your comments would be highly appreciated.
Np, glad to help.
Try this one?
when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] if { !($uri starts_with "/alpha" || $uri starts_with "/beta") } { HTTP::respond 301 Location "https://xyz.com/alpha" } }/Patrik
- Tanuj_90312
Nimbostratus
Thanks Patrik, I have applied the irule and redirection seems as expected. But have to wait until Monday to get this verified if everything is in place now from application perspective as well. Thanks again
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