1

I want to have various development (say dev.example.com) and staging environments of a WordPress multisite (example.com). For this it would be great if WordPress wouldn't redirect to what it considers the canonical domain name.

I'm running into trouble with this in my wp-config.php:

define('DOMAIN_CURRENT_SITE', gethostname());

It redirects to example.com or gives me database errors.

This is after wp search-replace example.com dev.example.com.

Is it possible to turn off this redirection? If so, how?

  • gethostname()) can't be asked from wp-config.php. It's too early. Try init or, depends of configuration, something later. Use a plugin, e. g. Debug Bar plus Debug Bar Action Hooks to watch what happens early and what happens later. – Max Yudin Jul 5 at 19:28
  • echo gethostname(); exit(); in wp-config.php looks fine to me. But I'll try Debug Bar Action Hooks to see if I can hook around the redirect. – fifi finance Jul 6 at 9:26
  • exit(); in wp-config.php is very bad idea. No WordPress environment in this case. – Max Yudin Jul 6 at 17:18
1
+50

In addition to modification of wp-config you might need to check .htaccess too, if there are any pointers to subfolder.

After that, you might need to replace the values in DB tables wp_site and wp_blogs.

0

From: Velvet Blues

To turn off Canonical URL Redirection, you can add the following code to your theme’s functions.php file.

remove_filter('template_redirect','redirect_canonical'); 

or use the plugin: Disable Canonical Redirects Plugin

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.