How to change the port in URL?

I want to change the port for all the requests made from the website to my application server.

For example, my website makes requests to http://myserver.com:8080 but I want to switch the port to 3000. That is,
https://myserver.com:8080/path?query=1#hash should go to https://myserver.com:3000/path?query=1#hash.

You may create a “Replace String” rule by specifying the URL and defining condition to replace original port with custom port.

Replace 8080 With 3000
If request URL Contains https://myserver.com


Rule can be imported from link: Requestly - Lightweight Proxy to Intercept & Modify HTTP(s) requests

If 8080 can also be present anywhere else as a substring in the URL, simple string replacement might not work for you. And, you may want to find the port in URL using Regex matching and replace with port 3000. In that case, you may create “Redirect Request” rule as:

If request URL Matches (RegEx) /https:\/\/myserver\.com:([0-9]+)\/(.*)/
Redirect to https://myserver.com:3000/$2

Note: $1 variable is first regex group i.e. port whereas $2 variable is the string after port (path + query string + hash).


Rule can be imported from link: Requestly - Lightweight Proxy to Intercept & Modify HTTP(s) requests