I'm really battling with something here. I'm trying to change my site to go from www. to non-www, and also http:// to https://
I've updated the settings in options-general.php (WordPress Address (URL) and Site Address (URL)). Both of these are using the non-www version, and also https:// now.
I've also updated the cookie setting in wp-config.php:
define( 'COOKIE_DOMAIN', 'mysite.co.uk' );
I can access the wp-admin just fine on https AND the non-www version. However, index.php just wants to keep me going in an infinite loop, reloading the homepage until it the browser gives up. I can't believe how hard this has been!
Anyone got any suggestions on what to try? I've spent 3 hours so far, on something that should have taken minutes.
For what it's worth, I have disabled ALL the plugins (in case it was one of them being weird), but still, it doesn't work.
It's probably worth mentioning that this has to be a WP issue, as editing index.php work fine if I just put this in it:
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
echo header();
echo "FOO";
UPDATE: Interestingly, I thought I would just go through the code and try to see where its screwing up. It gets to /wp-includes/template-loader.php, and then gets into the loop here:
do_action( 'template_redirect' );
...I don't knoew where it goes after that though? (to try and debug more)
UPDATE 2: I just installed this plugin: https://wordpress.org/support/plugin/debug-wp-redirect/ . Its super old, but it has shown me where the redirect is coming from:
Debug WP Redirect
Location: https://mysite.co.uk/
Status: 301
Backtrace:
File: /home/rachel/web/mysite.co.uk/public_html/wp-includes/class-wp-hook.php
Line: #298
Function: redirect_canonical
Arguments:
array(1) {
[0]=>
string(27) "http://mysite.co.uk/"
}
I just don't know why its failing (and using http instead of https here, which I guess is where the loop is coming from)
UPDATE 3: I don't know why, but this ONLY happens on the homepage!
http://www.foo.co.uk/wires-eyewear/
http://foo.co.uk/wires-eyewear/
https://www.foo.co.uk/wires-eyewear/
https://foo.co.uk/wires-eyewear/
All work fine. But:
http://www.foo.co.uk
http://foo.co.uk
https://foo.co.uk/
http://foo.co.uk
...all get stuck in an infinite loop. Eugh, this is so frustrating!
UPDATE 4: I've managed to get a stack trace, but I don't understand what is going on.
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/class-wp-hook.php
PHP message: Line: #298
PHP message: Function: debug_wp_redirect
PHP message: Arguments:
PHP message: array(2) {
[0]=>
string(28) "https://ladympresents.co.uk/"
[1]=>
int(301)
}
PHP message:
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/plugin.php
PHP message: Line: #203
PHP message: Class: #WP_Hook
PHP message: Function: apply_filters
PHP message: Arguments:
PHP message: array(2) {
[0]=>
string(28) "https://ladympresents.co.uk/"
[1]=>
array(2) {
[0]=>
string(28) "https://ladympresents.co.uk/"
[1]=>
int(301)
}
}
PHP message:
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/pluggable.php
PHP message: Line: #1181
PHP message: Function: apply_filters
PHP message: Arguments:
PHP message: array(3) {
[0]=>
string(11) "wp_redirect"
[1]=>
string(28) "https://ladympresents.co.uk/"
[2]=>
int(301)
}
PHP message:
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/canonical.php
PHP message: Line: #516
PHP message: Function: wp_redirect
PHP message: Arguments:
PHP message: array(2) {
[0]=>
string(28) "https://ladympresents.co.uk/"
[1]=>
int(301)
}
PHP message:
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/class-wp-hook.php
PHP message: Line: #298
PHP message: Function: redirect_canonical
PHP message: Arguments:
PHP message: array(1) {
[0]=>
string(31) "http://www.ladympresents.co.uk/"
}
PHP message:
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/class-wp-hook.php
PHP message: Line: #323
PHP message: Class: #WP_Hook
PHP message: Function: apply_filters
PHP message: Arguments:
I'm thinking this is now more and issue with the www. being taken out of the URL. I just don't get why though. I have every single plugin disabled, I've fully migrated the DB over (I even tried using a plugin to search and replace the DB and replace the old URL with the new one), and still the homepage refuses to work! There is either a major bug I've stumbled across, or something else at play. This is the bit this is baffling me:
PHP message:
PHP message: File: /home/rachel/web/ladympresents.co.uk/public_html/wp-includes/class-wp-hook.php
PHP message: Line: #298
PHP message: Function: redirect_canonical
PHP message: Arguments:
PHP message: array(1) {
[0]=>
string(31) "http://www.ladympresents.co.uk/"
}
The URL's are perfect up to that part, and then it randomly changes it back to not only http://
, but also add's the www.
bit in again!
UPDATE 4: So the plot thickens! It now turns out the problem is when using a custom page for the homepage!
If I change the Front page displays to "Front page displays" (instead of "A static page (select below)" , then it works... but obviously I have a rubbish looking homepage, that has nothing we need on there. I've tested this with different themes, and they all have the same problem. ARGH!