When incoming requests match
- Enter the following expression in the Expression Editor:
not http.host in {"m.example.com"} and (http.user_agent contains "mobi" or http.user_agent contains "Mobi")
Then
- Type: Static
- URL:
m.example.com
- Status code: 301
Create a redirect rule to redirect visitors using mobile devices to a different hostname.
The following examples will redirect visitors using mobile devices — based on the request user agent string — to a different hostname.
This example static redirect will redirect requests for the current zone (example.com
) from mobile users to m.example.com
without preserving the URI path in the original HTTP request.
When incoming requests match
not http.host in {"m.example.com"} and (http.user_agent contains "mobi" or http.user_agent contains "Mobi")
Then
m.example.com
Notes about this example:
not http.host in {"m.example.com"}
condition prevents redirect loops.http.host
condition of the rule's filter expression.This example single redirect will redirect requests for the current zone (example.com
) from mobile users to m.example.com
, keeping the URI path of the original HTTP request.
When incoming requests match
not http.host in {"m.example.com"} and (http.user_agent contains "mobi" or http.user_agent contains "Mobi")
Then
concat("https://m.example.com", http.request.uri.path)
Notes about this example:
not http.host in {"m.example.com"}
condition prevents redirect loops.http.host
condition of the rule's filter expression.