Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#30581 assigned defect (bug)

http/https pages have different canonical URLs

Reported by: betzster's profile betzster Owned by: joostdevalk's profile joostdevalk
Milestone: Future Release Priority: normal
Severity: normal Version: 2.9
Component: Canonical Keywords: needs-refresh https SEO
Focuses: Cc:

Description

If you have SSL turned on, but don't force redirect, http and https pages will have different URLs. Ideally, I think the canonical URL should always use http unless FORCE_SSL is turned on.

Even a filter for rel_canonical would be better than what we have now. Unhooking and creating your own version of rel_canonical() works, but if multiple plugins do this, you end up with multiple canonical URLs set on every page.

Related: #18660, #14458

Attachments (1)

30581.1.diff (1.1 KB) - added by peterwilsoncc 9 years ago.

Download all attachments as: .zip

Change History (18)

#1 @johnbillion
9 years ago

  • Component changed from General to Canonical
  • Milestone changed from Awaiting Review to Future Release

Note that FORCE_SSL doesn't exist yet. See #28521.

I think this can go hand in hand with #28521. There are too many gotchas if we try to automatically enforce any given scheme on a site. See #29708.

#2 @johnbillion
9 years ago

  • Version changed from trunk to 2.9

#3 @peterwilsoncc
9 years ago

30581.1.diff forces the scheme of the rel_canonical URL to match that of the home page defined in options > general.

The current behaviour remains for URLs without the http, https or relative protocols (check is taken from get_home_url).

#4 @peterwilsoncc
8 years ago

  • Keywords needs-refresh added

#5 @johnbillion
8 years ago

  • Keywords https added

#6 @newash
8 years ago

  • Keywords changed from needs-refresh, https to needs-refresh https

+1 for the filter option, it would be really nice and also non-intrusive.

#7 @joemcgill
8 years ago

Just ran into this myself. A filter would be nice, but in the mean time, forcing the site to respect the scheme set in the home option as 30581.1.diff suggests so the canonical URL doesn't change based on context.

#8 @joemcgill
8 years ago

Alternately, it looks like the approach in #36168 would be to replace the get_permalink() call with a call to a new function, get_canonical_url().

This ticket was mentioned in Slack in #core-http by joemcgill. View the logs.


7 years ago

#10 @joostdevalk
6 years ago

  • Keywords SEO added
  • Owner set to joostdevalk
  • Status changed from new to assigned

#11 @SergeyBiryukov
6 years ago

If you have SSL turned on, but don't force redirect, http and https pages will have different URLs.

Found a related issue: if you have a static home page set, it does force a redirect. Posts and other pages don't.

#12 @SergeyBiryukov
6 years ago

  • Milestone changed from Future Release to 5.0

#13 @palmiak
6 years ago

The filter was introduced in wp_get_canonical_url in WP 4.6. I think that adding another filter in rel_canonical would be a duplicate.

#14 @pento
5 years ago

  • Milestone changed from 5.0 to 5.1

#15 @pento
5 years ago

  • Milestone changed from 5.1 to 5.2

#16 @johnbillion
5 years ago

  • Milestone changed from 5.2 to Future Release

@joostdevalk Wanna pick this up again in 5.3?

#17 @joostdevalk
5 years ago

Is there a way for us to detect that https is "working" for a site? Because if so all our canonicals should always be https.

Note: See TracTickets for help on using tickets.