Replace Strings (Switch Hosts, API Endpoints)

Page Type
Meta Title
Meta Description
Category
HTTP Rules (Modify Traffic)
Publish
Publish
Path
/http-rules/replace-strings
ย 

Replace Strings

Replace Rule allows users to replace a string (or matching pattern) with another string in the URL.
notion image
  1. Source Condition: Source condition is where you set criteria for the rules. You can useย URL,ย Host, orย Pathย withย Regex,ย Contains,ย Wildcard, orย Equalsย to match the source request. Learn more about source conditionsย here.
  1. Destination URL: The destination to which the users will be redirected based on the source condition.
  1. Source Filters: You can define better targeting conditions and restrict rules to be applied on specific web pages (or domains), request types, request methods, or request payloads. Learn more about source filtersย here.

Popular use cases

  • Switch Domains:ย To test your app with the new changes done on the local server, you can use replaceย my-app-server.comย withย localhost:4000ย using Replace Rule. By this way, you can test your app without having to change any of your code.
  • Change Query Parameter Values:ย You can change the values of query parameters present in a URL. For example: Changingย ?dl-0ย toย ?dl=1ย in a dropbox URL downloads the file directly without going to the usual preview page.
  • Fix broken/updated URLs:ย There might be situations where you might be using links to some documentation or blog posts that have been changed/updated, however, you don't want to change the URLs in your code. In such cases, you can use replace rule to redirect the old resource to new one.
Video preview
ย 
โšก