markjaquith / WordPress-Skeleton

Basic layout of a WordPress Git repository. I use this as a base when creating a new repo.
1.85k stars 600 forks source link

Possible SEO/canonicalization issues when setting WP_HOME constant #88

Closed kacy- closed 9 years ago

kacy- commented 9 years ago

Hello and thanks for the great project. I'm using wp-skeleton to save on memory with opcache, and it's working quite nicely.

A marketer I work with noticed that, around the time we changed to using wp-skeleton, organic keywords dropped and Google Analytics now reports canonicalization/duplicate content issues.

Sure enough, when we tested, all the sites setup with wp-skeleton were not exhibiting the normal WP behavior of redirecting visitors to the FQDN in Settings > General > Site Address (URL). For example, even if the value was http://domain.com, WP would now would permit www.domain.com and domain.com without performing redirection.

The sites not using wp-skeleton (there are a few plugins like NGG that break with wp-skeleton, their fault and not wp-skeleton's), were behaving as expected by redirecting to the Site Address value.

The issue is corrected when we comment out the lines in wp-skeleton's custom wp-config.php that set the WP_HOME constant. Specifically, these lines:

        if ( ! defined( 'WP_HOME' ) ) {
              define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
        }

Once this is done, it works as expected. So it appears that by setting WP_HOME, it doesn't just disable changing of the Site Address value in settings, but it also disables the normal redirection behavior.

I've tested with these lines commented out and every other part of the site still works, whether we use www. in the setting or not, it redirects as it should and no page objects fail to load.

I wanted to report this but also ask if this is known/expected behavior, as well as if anyone see any issue with leaving out this stanza.

Thank you!

mralexho commented 9 years ago

Hi @kacy- , where do you see the lines in wp-config.php?

fgilio commented 9 years ago

Ajam... Just checked and those lines are not there.

Anyway, I'm also in doubt. Is this the expected behavior when defining 'WP_HOME'?

kacy- commented 9 years ago

Doh! So sorry, this was intended for https://github.com/htmlgraphic/WordPress-Skeleton