0

After setting up multisite on http://localhost, requests to http://localhost redirect to http://production-domain.com (Including "Log In").

  • Where is the production domain information even being retrieved from?
  • I suspect the cause is modifications to wp-config.php or .htaccess files. If I revert these changes, the site works again properly (albeit without multisite)

More detailed symptoms:

The WordPress site itself stops loading properly. When loading http://localhost:

Log In is also affected:


How I configured multisite.:

Added following lines to c:/www/wp/wp-config.php:

define( 'WP_ALLOW_MULTISITE', true );

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost');
define('PATH_CURRENT_SITE', '/'); // Also tried: define('PATH_CURRENT_SITE', '/wp/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

(Already had this in /www/wp/wp-config.php:)

// Overwrites the database to save from constantly editing the DB
define('WP_HOME','http://localhost/');
define('WP_SITEURL','http://localhost/wp');

c:/www/.htaccess:

# Original version left as comments at bottom.
# Note WordPress is installed in the wp subdirectory
# so there is another file, c:/www/wp/.htaccess
# which I have tried both editing and leaving intact.


RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L]
RewriteRule . index.php [L]

# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
# RewriteRule ^index\.php$ - [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /wp/index.php [L]
# </IfModule>
#
# # BEGIN WordPress
# <IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /wp/
# RewriteRule ^index\.php$ - [L]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /wp/index.php [L]
# </IfModule>
#
# # END WordPress
1

OK. I figured it out: When moving to multisite, manually overriding WP_HOME and WP_SITEURL like below doesn't work anymore:

// Overwrites the database to save from constantly editing the DB
define('WP_HOME','http://localhost');
define('WP_SITEURL','http://localhost/wp');

I fixed this by manually changing the database so WP_HOME is http://localhost and WP_SITEURL is http://localhost/wp.

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.