Servers commonly use the User-Agent Request Header to identify their client's application type, operating system, software vendor, or software version. Based on the User-Agent string, the server selects suitable content to send in response. For instance, when a website opens on a mobile device, it usually looks quite compact and different from the way it opens on a desktop.
By modifying the User-Agent string, you can control how a website interprets the client accessing it. This capability is especially useful for testing and debugging applications to observe how they respond to different devices and browsers.
Benefits of Modifying User Agents
-
Device-Specific Testing: View and test mobile, tablet, or desktop versions of a website.
-
Browser Compatibility Checks: Analyze how your application behaves in different browsers.
-
Debugging: Verify if content adapts correctly based on User-Agent information.
How to Modify User Agents in Requestly
Open HTTP Rules and Create a New Rule
Navigate to the HTTP Rules section in the Requestly app. Click on the + New Rule
button and select "User-Agent" from the available options.
Define the Rule Name and Description
Provide a meaningful name for the rule to keep your setup organized. Optionally, add a brief description to explain its purpose for easier identification later.
Define the Source Condition
Source Condition specifies the criteria for matching requests. You can target requests using the following attributes:
-
URL, Host, or Path: Define what part of the request should be matched.
-
Operators: Choose from Regex, Contains, Wildcard, or Equals to apply precise matching logic.
For more detailed guidance, refer to the Source Conditions Guide.
Select Device or Browser
Choose whether you want to emulate a specific device or browser. Requestly provides preset options such as Android Phones, iPhones, or popular web browsers like Internet Explorer or Safari.
Configure Device or Browser Type
Select the exact version or model you wish to emulate. You can either choose from the predefined options or define a custom User-Agent string to meet your testing needs.
Save and Activate the Rule
Once all conditions are set, click Save to store the rule. Toggle the rule ON to activate it. You can now test your setup by visiting the targeted websites.
Examples of User-Agent Strings
-
Android Device:
Mozilla/5.0 (Linux; Android 10; SM-G960F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Mobile Safari/537.36
-
iPhone:
Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1 Mobile/15E148 Safari/604.1
-
Desktop Chrome:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
Test Your Rule
Use the Test feature in Requestly to confirm the rule's behavior. Input the URL of a website and monitor how the content adapts to the new User-Agent string. This ensures that the desired changes are applied successfully.
The mobile version of the spreadsheet is loaded on the desktop.