Overview
You can use this document to learn how to redirect mobile devices to mobile websites for full-site integrations.
Every request made to the internet includes a "User-Agent" header that identifies the device sending the request. StackPath uses this information to adjust the response, based on the contents of the header.
Step 1: Create a rule
- In the StackPath Control Portal, in the left-side navigation, click Sites.
- Locate and select the desired site.
- The selected site must have CDN enabled.
- In the left-side navigation, click Edge Rules.
- Click Edge Rules.
- Scroll down to Delivery Rules, and then click Add Delivery Rule.
- In Rule Name, enter a descriptive name for the rule.
- Create and save the following EdgeRule:
If Header Matches Regular Expression /User-Agent: *(iPhone|Android).*/
Then https://m.yourmobiledomain.com
- Replace m.yourmobiledomain.com with your actual mobile connection subdomain.
Note:
The Matches Regular Expression option matches any User-Agent Header that includes iPhone or Android, and then redirects the request to m.yourmobiledomain.com.
This match is case-sensitive and will only work if the incoming User-Agent matches the casing as defined in the rule.
Step 2: Verify the rule
To verify this rule, run a cURL command with the -A option, applying a custom user-agent header to the request, which will trigger the rule as if it were a mobile user.