Forum Discussion
12 Replies
- The_YCirrus
Mohamed,
if you are looking for a static redirect then this should work
when HTTP_REQUEST { if {[string tolower [HTTP::host]] ends_with "example.com"} { HTTP::redirect "https://example.com/xyz" } }
- HamishCirrocumulus
If www.example.com and example.com are the same VS, then this is the source of your looped redirect. You hit the same host again (example.com) and then redirect because your HOST ends with example.com...
You need to check the the URI is NOT /xyz already...
e.g
when HTTP_REQUEST { if { ([HTTP::uri] begins_with "/xyz") } { return } if {[string tolower [HTTP::host]] ends_with "example.com" } { HTTP::redirect "https://example.com/xyz" } }
Change begins_with to equals depending on what the rest of the content looks like...
- HamishCirrocumulus
Because I was typing on the fly. It's starts_with not begins_with
- The_YCirrus
If you are already doing an HTTP --> HTTPS redirect then this irule should only be added to your HTTPS Virtual server. Hope that helps
- natheCirrocumulus
Mohammed,
Plenty of information/examples if you search for HTTP::redirect command in DevCentral.
Here's the documentation for HTTP::redirect to get you started.
N
- Mohammed_AkramAltostratus
Thanks for the reply
all are working except if a user add www. its giving error . For the URL as am using wildcard cert
http://example.com or https://example.com or example.com or
http://www.example.com or https://www.example.com
should be redirect to https://example.com/xyz
- natheCirrocumulus
a quick search of DC comes up with this: redirect www to https
- Mohammed_AkramAltostratus
if a user enter https://www.example.com "HTTPS" then it is not redirecting . if a user hit http://www is redirecting but only https:// giving error.
- Mohammed_AkramAltostratus
It says redirected you too many times
- The_YCirrus
Seems like you are having a redirect loop. Can you share your VS on config on port 80 and 443?
list ltm virtual <virtual_server>
- Mohammed_AkramAltostratus
Below are the config on HTTP and HTTPS VIP
(HTTP_redirected)
list ltm virtual test-directory-redir
ltm virtual test-directory-redir {
creation-time 2019-06-17:13:17:31
destination X.X.X.X.:http
ip-protocol tcp
last-modified-time 2019-06-18:23:46:04
mask 255.255.255.255
profiles {
http { }
tcp { }
}
rules {
_sys_https_redirect
}
source 0.0.0.0/0
source-address-translation {
type automap
}
translate-address enabled
translate-port enabled
vs-index 43
}
___________________________________________________________________________________________________________
(HTTPS)
list ltm virtual test-directory
ltm virtual test-directory {
creation-time 2019-06-17:13:15:56
destination X.X.X.X:https
ip-protocol tcp
last-modified-time 2019-06-18:23:34:03
mask 255.255.255.255
persist {
dest_addr {
default yes
}
}
policies {
Gzip { }
}
pool Elaa_FII_Pool
profiles {
Elaa_Client_SSL {
context clientside
}
http { }
httpcompression { }
tcp { }
}
rules {
X-Forwarded-For
ends_with_www
}
source 0.0.0.0/0
source-address-translation {
type automap
}
translate-address enabled
translate-port enabled
vs-index 42
}