WordPress.org

Make WordPress Core

Opened 4 months ago

Last modified 4 months ago

#49369 new defect (bug)

redirect_canonical() should strip trailing protocols

Reported by: onlyonemj Owned by:
Milestone: Awaiting Review Priority: normal
Severity: major Version: 5.3.2
Component: Canonical Keywords: needs-patch needs-unit-tests
Focuses: Cc:

Description

I was crawling some of my sites as I was setting up SEO strategies and found really odd 301 redirects on all tested sites.

  1. https://domain.com/http:// redirects to https://domain.com/http:/ (one forward slash less). So it's basically a nonexistent page redirecting to another nonexistent page
  1. To figure what could be causing this I needed to check if this was happening to just this site or others. I discovered that all sites suffered the same issue regardless of host or webserver stack.
  1. Wondering if Cloudflare a common plugin was causing it, I unproxied and entered all the sites in dev mode and had all plugins disabled and the problem still persists

Spiders/crawlers pick this up - appending http:// to end of root URLs manually is not required.

This issue persists - likely a bug in WordPress redirect API. Anybody care to replicate and confirm? Is this a bug?

Change History (2)

#1 in reply to: ↑ description @SergeyBiryukov
4 months ago

  • Component changed from HTTP API to Canonical
  • Focuses rest-api removed
  • Keywords needs-patch needs-unit-tests added; 2nd-opinion dev-feedback needs-dev-note removed
  • Summary changed from Phantom redirects to redirect_canonical() should strip trailing protocols

Hi there, welcome to WordPress Trac! Thanks for the report.

Replying to onlyonemj:

This issue persists - likely a bug in WordPress redirect API. Anybody care to replicate and confirm? Is this a bug?

Yes, this appears to be an issue with the redirect_canonical() function, which strips multiple slashes from URL, but doesn't handle a case like this. It seems stripping http:// completely would be the expected behavior here.

#2 @onlyonemj
4 months ago

Thanks for replying @SergeyBiryukov, not a hardcore coder but the multiple slashes link you gave looks like it strips extraneous forward slashes at the end of URLs which is expected behaviour in the case of folder paths. It doesn't address whether if WP is responsible for creating the http: prepend to the forward slashes? Is WordPress creating those or are the crawlers wrong? One crawler detects it but Screaming Frog isn't. The http:// page appending right after root does not exist anywhere nor was ever created.

Last edited 4 months ago by onlyonemj (previous) (diff)
Note: See TracTickets for help on using tickets.