I have a local WordPress install running through MAMP. It's local domain is example.dev

I also have the install working with xip.io. It's at example.dev. (0's being my ip address).

Right now the only way I seem to be able to get xip.io working is to add

define('WP_HOME', 'http://example.dev.');
define('WP_SITEURL', 'http://example.dev.');

to my wp-config.php file.

This forces anyone going to example.dev to go to example.dev.

The issue is at the office, my computer has a static IP address. At home, it does not. So if I am in the office and go to example.dev. in my local browser or in a browser on the network, it all works fine.

But if I am at home, example.dev redirects to example.dev. which does not work because my IP is no longer static.

So I need to be able to view the site locally at example.dev and on a LAN connected computer at example.dev. thus eliminating the static IP issue when I'm at home.

Any help would be appreciated!

1 Answer 1


Could this be resolved by a hosts file entry that always routed relevant host requests back to local host?

  • That's a good idea. Something like a redirect? Something that takes all traffic asking for example.dev. and sends it to example.dev? My question then is, how do I do that? lol Oct 25, 2017 at 15:28
  • host file entries override dns entries, but they are a pretty basic construct - they match a single IP address to one or more host names.
    – hughc
    Oct 26, 2017 at 22:40
  • If you're not trying to serve the site to other people, but just make it available to you, on the local machine, then a host file entry to map to `example.dev' would be enough to keep the site working regardless of the changing dns conditions (and machine IP). The other thing to keep in mind here is that out of the box, Wordpress can only be set up on a single base URL; it will rewrite all links relative to that URL. So if example.dev is the site's Wordpres URL, and you hit example.dev. then all links off the homepage will point to example.dev
    – hughc
    Oct 26, 2017 at 22:47
  • Yeah, I think I am understanding what you're saying. But you kinda redefined my problem. WordPress IS redirecting all traffic from example.dev. to example.dev, and that's the issue. Is there any way to have the WordPress URL be example.dev. on the LAN and example.dev on my machine? I have recently tried a root relative url plugin in order to get this to work. It does work, but only for single WP install, not multisite. I definitely need multisite support. Oct 30, 2017 at 17:15
  • The technique that I use for serving many test domains from localhost (which I assume would be applicable to multisite) is to create a public wildcard DNS record that points *.localdev.mydomain.com to Appreciate that might not be your aim here, if availability to other LAN machines is important. Plugins like the one you describe are fighting against a core assumption of WP, so it's unsurprising they struggle with things like multisite.
    – hughc
    Oct 31, 2017 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.