This EdgeRule is used to redirect mobile devices to mobile websites, in a Full Site Integration situation. Every request made to the internet will include a "User-Agent" header that identifies the device sending the request. StackPath can use this information to adjust the response, based on the contents of this header.
If you have not already, please check this guide to get started.
Creating the Rule
- Select a Site you would like to create the rule for, this Site will need CDN Enabled
- Navigate to your EdgeRules tab
- Select Add Delivery Rule
- In the IF section, add a Header Matches Regular Expression option to
/User-Agent: *(iPhone|Android).*/to catch mobile users.
- In the THEN section add a Redirect Rule with the value of
https://m.yourmobiledomain.com. Remember to replace m.yourmobiledomain.com with your actual mobile connection subdomain.
The Matches Regular Expression option defined above will match any User-Agent Header that includes iPhone or Android and redirect to m.yourmobiledomain.com. It is important to keep in mind that this match is case-sensitive and will only work if the incoming User-Agent matches the casing as defined in the rule. Please remember to replace the redirect link with the actual domain you use for the mobile version of your website.
Verifying the Rule
This rule can be validated by a cURL command with the -A option applying a custom user-agent header to the request, triggering the rule as if it were a mobile user.
If any questions arise or any assistance can be further provided, feel free to drop us a line at email@example.com or open up a chat with our 24/7 live support, we'll be happy to help you out.