How to use Rewrite URL tool in Charles Proxy

Dinesh Thakur - Sep 11 - - Dev Community

There are many scenarios where you might need to rewrite the URL of a request, such as testing different environments, redirecting traffic for debugging, or bypassing certain network restrictions. However, configuring URL rewriting in Charles Proxy can be a complex process, involving several steps and hard-to-find options.

Imagine if you could accomplish the same task with just a couple of clicks, all within your browser. With Requestly’s Replace String rule, you can easily rewrite URLs in seconds, without going through Charles proxy’s steep learning curve. Simply install the Requestly Chrome extension and enjoy a seamless, user-friendly experience.

Charles Proxy’s Rewrite Tool: How It Works

Configuring the Rewrite tool in Charles Proxy can be a time-consuming process. It requires navigating through a series of options, which can be difficult to find and set up, especially for users unfamiliar with the tool.

How to Configure Charles Proxy’s Rewrite Tool

  • Open Charles Proxy and ensure that your proxy is enabled and traffic is being captured.

  • Navigate to the Tools Menu:

    • In the top menu, click on Tools.
    • From the dropdown, select Rewrite.

  • This will open the rewrite settings window Here check Enable rewrite box and click Add

  • Rename the rule to your liking and add a location to which the rule should be applied to

    • Protocol: Here you can select your site’s protocol http or https
    • Host: Here you can enter the host/domain that you want to apply the rule to.
    • Port: You can specify the port on which your site is running.
    • Path: Define the path if you want the rule to apply only to specific paths on the host.
    • Query: Here you can define the query parameters that should be targeted.

  • Now Save the location and click on add in the actions section

    • Type: The type tells Charles what to modify. Here we have to select the type of rule we want to use
    • Match: You need to tell Charles when to apply the rule. This is done by matching specific text in the request URL. Here we want to replace the value of google.com with bing.com so we will match the URL google.com.
    • New/Replace: Once a match is found, Charles replaces the text you’ve specified. For example, in this case we want to replace the google.com host, Charles will replace it with the new value we provided.
  • After saving this you should be able to see the rule and its modifications

  • Now visit the site you selected and you can see the URL change.

While Charles Proxy’s Rewrite URL tool is highly versatile, it does require multiple steps to set up and configure properly. Users often need to navigate through the Rewrite Settings, define conditions, and carefully input Replacing value to ensure accuracy. Additionally, as Charles is a desktop application, switching between your testing environment and the proxy can be cumbersome.

Replace String rule in requestly

Say goodbye to complex setups with Charles Proxy and streamline your debugging workflow using Requestly’s Replace String rule. While Charles Proxy requires multiple steps and a separate desktop application to rewrite the url, Requestly offers a faster, more intuitive solution directly within your browser. Easily simulate different devices or test API requests with just a few clicks—no need to switch between applications or configure complex rules.

  • Install Requestly Extension: Download and install requestly’s browser extension for your browser.
  • Open Requestly Dashboard: Click on the Requestly icon in your browser toolbar to open the Requestly dashboard.
  • Configure Replace String rule: Here you can first select a condition and rewrite the url for any request you want.

  1. Rule Name: here you can edit the rule’s title and description which helps identify it later.
  2. Source Condition: Here you define the condition for the rule to run, you can use inbuilt functions like contains or equal or you can write custom regex or wildcards for pattern matching.
  3. Replace With: Here you have first enter the string you want to replace in the url and then give the value you want to replace the string with. Here we will replace google.com withbing.com.

Now you can save the rule and test it on your desired website, or if you do not want to go through the hassle of setting it up yourself, we have created a shared list of this rule for replacing google domain with bing for you. Go ahead and import it by clicking this button below

Install Requestly Browser Extension if not installed already

Try This Rule

Or create your own Rule by following the setups below

Interactive guide

Check out this interactive and easy explanation of how to create this rule :

Guide

Other Use Cases for Requestly’s Redirect Rule

Redirect rule in requestly is a powerful tool and can serve many purposes, it can also be used for other usercase like :

  1. Testing Staging vs. Production Environments: Automatically redirect requests from a production URL to a staging environment, allowing you to safely test features before deployment.
  2. A/B Testing Without Server Changes: Use the Redirect Rule to direct traffic to different versions of a webpage or app, making A/B testing faster without needing to deploy code changes.
  3. Avoiding External API Calls: Redirect API requests to mock servers or local environments during development to avoid affecting live data or incurring unnecessary API costs.

Migrate from Charles proxy

If you already have a Charles Proxy setup and want to give Requestly a try, You can import these tool settings in Requestly in just few clicks

Requestly currently supports following tools that you can import from Charles Proxy:

  • Rewrite
  • Map Local
  • Map Remote
  • No Caching
  • Block lists
  • Block Cookies

Steps to import

  • In Charles Proxy, go to the top menu bar and select Tools > Import/Export Settings.

  • In the popup window that appears, switch to the Export tab. Under the Tools section, select the tools you want to export and click the Export button at the bottom right.

  • Upload or drag your exported Charles .xml file into Requestly.

  • Once the import is successful, your Charles Proxy settings will be converted into Requestly rules.

Conclusion

I hope this article has given you a clear understanding of both the rewrite URL tool in Charles Proxy and how Requestly can achieve the same results with greater ease. While Charles Proxy effectively handles the task, Requestly offers a more streamlined and efficient experience.

Since Requestly operates directly from your browser and leverages built-in browser APIs, there’s no need for complex SSL configurations, eliminating the SSL issues often encountered with Charles Proxy. Plus, you don’t need to switch between different tools—everything you need is right in your browser.

Requestly’s exceptional support is reflected in its 4.4 ⭐ rating from over 1,200 users on the Chrome Web Store, proving it’s a great product with top-tier support.

. . . . . . . .
Terabox Video Player