I'm fairly new to Wordpress building and had a great site built and running only on my local network. I found a suggestion to make it publicly accessible by adding the following to my wp-config file. After adding this and restarting, everything crashed and I can't access the Dashboard or my site on any combination of urls. What all would this code alter when it ran that I might need to fix?
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' || $_SERVER['REMOTE_ADDR'] == '::1') {
// accesing site from my local server
define('WP_SITEURL', 'http://localhost');
define('WP_HOME', 'http://localhost');
} else if (strpos($_SERVER['REMOTE_ADDR'],'192.168.0.') !== false) {
// accesing site from another machine in my home network,
// all their (internal) network addresses begin with this number;
// the next line provides the server's own internal network address
define('WP_SITEURL', 'http://192.168.0.142');
define('WP_HOME', 'http://192.168.0.142');
} else { //accesing site from outside home
define('WP_SITEURL', 'http://myexternalip'); //replace by your external home IP
define('WP_HOME', 'http://myexternalip');
}
//error_log("Siteurl is ".WP_SITEURL);
Tried fresh manual install of Wordpress, tried deleting plugins, and tried removing the added code from the wp-config.php file but still no luck and getting a white screen of death/http error 500.
No debug error message or file created but do get a php_error.log with the following message:
Stack trace:
#0 /var/www/html/index.php(17): require()
#1 {main}
thrown in /var/www/html/wp-blog-header.php on line 16
[07-Apr-2023 20:11:15 Europe/London] PHP Fatal error: Uncaught Error: Call to undefined function wp() in /var/www/html/wp-blog-header.php:16
Stack trace:
#0 /var/www/html/index.php(17): require()
#1 {main}
thrown in /var/www/html/wp-blog-header.php on line 16
And here's the file content in my wp-blog-header.php file:
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}
* Loads the WordPress environment and template.
*
* @package WordPress
*/
if ( ! isset( $wp_did_header ) ) {
$wp_did_header = true;
// Load the WordPress library.
require_once __DIR__ . '/wp-load.php';
// Set up the WordPress query.
wp();
// Load the theme template.
require_once ABSPATH . WPINC . '/template-loader.php';
}