AdamJones
AdamJones

Reputation: 601

Url rewriting with Charles Proxy in order to run a wordpress site over a LAN?

I want to use Charles Proxy to share a local development PC's web server where I am developing sites on so that I can access the PC over my LAN to test on various mobile devices.

Having setup the correct ip address of my PC in the http proxy settings on various tablets they can all connect to the PC and this works fine.

The issue is that I need to test a wordpress site and as anyone that uses wordpress knows, it generates full url links between each page it serves. As the site normally runs on my PC the urls it generates are all http://localhost/wordpress/pagename.

So the issue is that if I access the same site from a remote device via the proxy (addressing http://192.168.1.200/wordpress/) it instantly redirects me to http://localhost/wordpress/pagename url in the mobile device and this fails to load as the tablet can't determine "localhost" correctly.

There must be a way of using one of Charles' various options to resolve this but I can't for the life of me work out which. I've tried remote maps and DNS spoofing but no joy.

Note, I'm completely aware that you can with SQL commands change the urls throughout a wordpress database but I just wanted to see if this was possible without undertaking this step as it would be a lot more flexible if I don't have to do that each time I want to preview sites via my other local LAN devics.

Upvotes: 0

Views: 3517

Answers (1)

Da-FyK
Da-FyK

Reputation: 1060

You can use Charles proxy feature called Rewrite Tool. I assume your local network uses 192.168.168.X IPs.

  1. Enable rewrite
  2. Add new rule and name it as you wish
  3. To Locations section add Protocol: http and Host: 192.168.168.X
  4. To Rules section add Type: body, Where: response, Match: localhost, Replace: 192.168.168.X

It may require some more tinkering but i hope you get the idea

Upvotes: 2

Related Questions