Forum Discussion
redirect http://www.{URI} & http://{URI} to https://{URI}
Hi We have a situation where the published website is needs http to https redirect and in the same time gives an error when accessed using www.{URI}
So may you help with the iRule syntax that : redirect both .{URI} & http://{URI} to https://{URI}, ofcourse while keeping the full URI path without change
- mofathy_63257Nimbostratus
Just an update: besides the above needs, it's also needed to redirect .{URI} to https://{URI}
The question is not entirely clear but if all you want is to redirect to https you might want to have a look at this pre-generated iRule (it comes with all modern versions of TMOS):
/Common/_sys_https_redirect
I would split it into two rules.
Apply this to the HTTP VIP:
when HTTP_REQUEST { HTTP::respond 302 Location "https://test.com[HTTP::uri]" }
Apply this to the HTTPS VIP:
when HTTP_REQUEST { if { [HTTP::host] eq "www.test.com" } { HTTP::respond 302 Location "https://test.com[HTTP::uri]" } }
That should take care of all the scenarios you mentioned.
/Patrik
- Mohamed_FathyNimbostratus
Hi,
Although it's an old question, but it was just tested now!!
We've applied it but didn't work, noting that our domain is in the format of : subdomain.domain.com.eg , so may the long format of domain causes an issue? any workarounds?
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