I want to have various development (say dev.example
) and staging environments of a WordPress multisite (example
). 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
or gives me database errors.
This is after wp search-replace example dev.example
.
Is it possible to turn off this redirection? If so, how?
I want to have various development (say dev.example
) and staging environments of a WordPress multisite (example
). 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
or gives me database errors.
This is after wp search-replace example dev.example
.
Is it possible to turn off this redirection? If so, how?
Share Improve this question edited Jul 24, 2019 at 21:53 the asked Jul 5, 2019 at 17:54 thethe 1,5682 gold badges13 silver badges32 bronze badges 3 |2 Answers
Reset to default 1 +50In 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
.
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
gethostname())
can't be asked fromwp-config.php
. It's too early. Tryinit
or, depends of configuration, something later. Use a plugin, e. g.Debug Bar
plusDebug Bar Action Hooks
to watch what happens early and what happens later. – Max Yudin Commented Jul 5, 2019 at 19:28echo gethostname(); exit();
inwp-config.php
looks fine to me. But I'll tryDebug Bar Action Hooks
to see if I can hook around the redirect. – the Commented Jul 6, 2019 at 9:26exit();
inwp-config.php
is very bad idea. No WordPress environment in this case. – Max Yudin Commented Jul 6, 2019 at 17:18