0

I tried to clone a wordpress multisite on localhost. Instead of loading http://localhost/test.org, requests are redirected to test.org. I've summarized different things I've tried to resolve this issue.

[Update: I've changed http://localhost/test.org to localhost/test.org]

In .htaccess, I've tried changing RewriteEngine from On to Off, and I've done a search and replace to change test.org to localhost\test.org. The cache is empty.

In the database, I've updated the following tables / values, changing test.org to localhost/test.org.

  • wp_options / siteurl
  • wp_options / home
  • wp_site
  • wp_sitemeta / siteurl
  • wp_blogs / domain
  • wp_#_options > siteurl (replacing # with the number of each site in the network)
  • wp_#_options / home
  • wp_#_options / fileupload_url

In wp-config.php, WP_HOME and WP_SITEURL are both localhost/test.org.

Here's the multisite config section in wp-config.php:

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'test.org');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

If I try to set DOMAIN_CURRENT_SITE to localhost/test.org, I get an error message saying: "The page isn’t redirecting properly", "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."

I thought that a plugin might be causing the problem, so I moved everything from wp-content/plugins to another folder.

I've cleared the browser cache and I've used a different browser.

Does anyone have recommendations for other steps I could try?

2
  • It's possible that Firefox has cached a redirect to test.org. If you update DOMAIN_CURRENT_SITE and try it in a private Firefox window (or a different browser entirely), does it work as expected?
    – Pat J
    Commented Jun 16, 2023 at 20:03
  • I tried a different browser, it's still redirecting.
    – ornisel
    Commented Jun 16, 2023 at 20:10

1 Answer 1

1

When moving a WordPress Multisite install to a different domain (such as from a live site to localhost), there are a few steps you need to follow to ensure that the site works correctly. These include updating the database and adjusting the wp-config.php file.

Firstly, the DOMAIN_CURRENT_SITE in your wp-config.php file should not include 'http://'. It should just be the domain name, so in your case it should be 'localhost'.

And there are several places in the database where you need to change the domain. Do properly change them, you can use a search and replace script or you can try a search and replace plugin like this one.

Remember to clear your browser cache before testing your site on localhost, as your browser may have cached redirects to your live site.

Then, make sure your hosts file on your local machine is set up to associate localhost with the local IP address.

If you still face issues, it might be related to your server configuration. For instance, if you're using Apache, ensure that your vhost file is properly configured. If you're using a tool like MAMP or XAMPP, ensure that the server software is properly configured to point to the correct directory for your site.

1
  • I've updated the database in a few more places and I've listed which tables and which values I've changed. Clearing my browser cache / using a different browser or a private window doesn't work. I'm still experiencing the same problems. The Apache vhost is configured the same way as another local wordpress site which works as expected. This site is still redirecting to the live site.
    – ornisel
    Commented Jul 21, 2023 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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