Site not loading after changing host IP address
-
I’m building a site locally for a friend to get the content correct before getting a hosting service like hostgator or godaddy. I’ve created a virtual machine on my laptop using Arch Linux (bridged network) and installed WordPress there. Everything works great when I’m on my home network. I can access the site through the IP address (192.168.1.222) or the hostname provided through the DNS on my router.
My problems occur when I try to take my laptop off my home network to collaborate with my friend. Obviously, I get a new IP address, so I’ve modified the wp-config.php file to automatically handle the change. Here is the code I added:
/** Automatically resets the home and site URLs to the current host's IP address */ $host_ip_addr = shell_exec("ip address show enp0s3 | grep inet | grep -v inet6 | awk {'print $2'} | sed 's/\/.*//'"); $host_ip_addr = preg_replace('/\s+/','',$host_ip_addr); define('WP_HOME', "https://".$host_ip_addr."/wordpress"); define('WP_SITEURL', "https://".$host_ip_addr."/wordpress");
I’m sure the code is working right because the URL generated is correct in my home network. But, when I’m anywhere else, the site won’t load and I get a spinning wheel in the browser. From the research I’ve done, I thought all I needed to do was re-point the home and siteurl settings. There must be something else I’m missing. Any help would be much appreciated.
- The topic ‘Site not loading after changing host IP address’ is closed to new replies.