How to properly setup MAMP and XIP

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.0.0.0.xip.io (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.0.0.0.0.xip.io');
define('WP_SITEURL', 'http://example.dev.0.0.0.0.xip.io');

to my wp-config.php file.

This forces anyone going to example.dev to go to example.dev.0.0.0.0.xip.io

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.0.0.0.0.xip.io 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.0.0.0.0.xip.io 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.0.0.0.0.xip.io thus eliminating the static IP issue when I'm at home.

Any help would be appreciated!

Topic dns local-installation domain urls Wordpress

Category Web


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

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.