WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#4773 closed defect (bug) (fixed)

Canonical URL addition causes redirection problems

Reported by: jbctech Owned by: markjaquith
Milestone: 2.3 Priority: high
Severity: critical Version: 2.3
Component: General Keywords:
Focuses: Cc:

Description

The addition of the canonical redirection in changeset 5890 and 5891 in SVN causes my site to display the following error message in Firefox:

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

In Safari, it displays:
Safari can’t open the page.
Too many redirects occurred trying to open “http://www.MySite.com/”. This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.

I am able to access /wp-admin, and tried changing themes and/or settings with no success. Once I revert back to 5889, it works fine.

Attachments (1)

canonical.php.diff (622 bytes) - added by jbctech 7 years ago.
Possible solution

Download all attachments as: .zip

Change History (33)

comment:1 DD327 years ago

Can you perhaps give some more information?
Are you using Apache? IIS?(What rewrite modules?)
What permalink structure? (Are you using any non-default Mod Rewrite options?)

I've not looked too closely at the code(Yet) but thats just general questions(But we need more info to track down the actual exact problem).

D

comment:2 jbctech7 years ago

D,

Sorry - here's a bit more information:

Apache 1.3.37 (Unix)

I believe it's all standard rewrite options - the permalink Structure is "Date and name based" and the only other plugin that modifies the .htaccess file is FAlbum.

comment:3 Mark7 years ago

I get this too.

Here is the information I see in the access log if it helps:

  • - [22/Aug/2007:14:08:06 -0400] "GET /wp-admin/upgrade.php HTTP/1.1" 200 821 "-" "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.2) Gecko/20070224 BonEcho/2.0.0.2"

and from there it stays at 301

The only cure was the first permalink option. Anything else causes the browser loop.

At revision 5916.

Tested in Camino too.

comment:4 markjaquith7 years ago

  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

I'll need the URL of the blog. The best way to diagnose problems here is using the LiveHTTPHeaders Firefox add-on.

Mark, for your problem I'll disable the canonical functionality in /wp-admin/

comment:5 markjaquith7 years ago

(In [5921]) No canonical-ness for wp-admin. see #4773

comment:6 Mark7 years ago

http://kirbymuxloe.net

/wp-admin is fine, no problem.

The actual blog gets the message.

Contact me if you want backend access to the blog or ssh

comment:8 Mark7 years ago

The problem continues either with
is_admin() or without that in canonical.php

I guess I'm the only one though so all I can do is revert to 2.2

Tried with the beta-1

I didn't mention there are no plugins and post preview does work albeit as Ryan describes.

comment:9 ryan7 years ago

Breaks category paging too.

comment:10 Nazgul7 years ago

I'm able to reproduce this.

On my blog, if I surf to http://localhost/blogsvn/, at the end of the redirect_canonical function 'http://localhost/blogsvn/'==$redirect_url and 'http://localhost/blogsvn/index.php'==$requested_url, thus forcing a redirect and going into an infinite loop.

For some reason, the $requested_url gets a bonus index.php from somewhere that's causing this issue.

comment:11 rejon7 years ago

  • Severity changed from major to critical

Yes, I get the same thing on overlap.org which is running the latest from SVN. The paging is broken on categories.

comment:12 westi7 years ago

See also #4862 possibly related

comment:13 markjaquith7 years ago

(In [5974]) Fix paging and preview links for canonical stuff. see #4773. fixes #4862

comment:14 follow-up: markjaquith7 years ago

(In [5978]) More cautious canonical-ness. Exclude IIS and POSTs. Better paging handling. Still a work in progress! see #4773

comment:15 in reply to: ↑ 14 jbctech7 years ago

Replying to markjaquith:

(In [5978]) More cautious canonical-ness. Exclude IIS and POSTs. Better paging handling. Still a work in progress! see #4773

Is there a way to disable this 'canonical-ness'? I'm still having this problem with the latest svn...

comment:16 ryan7 years ago

For now, you can comment out the last line in wp-includes/canonical.php. Of course, we'd appreciate it if you could try new versions as we release them so we can get it fixed for good. :-)

comment:17 matt7 years ago

Yes please don't disable without helping us identify the problem first, or it'll be broken for thousands of other people after the release.

comment:18 wantmoore7 years ago

  • Cc wantmoore@… added

I believe this may also be causing me some trouble on a site I've been developing recently. Site works fine until I enable the Front page/Posts page on the Options->Reading in the admin.

Info:
WP Trunk r6065
PHP 4.4.4
MySQL 4.1.22
Apache 1.3.37

Current rewriting being handled by WP via index.php - no .htaccess.

comment:19 wantmoore7 years ago

  • Cc wantmoore@… removed

comment:20 follow-ups: markjaquith7 years ago

wantmore,

What are your symptoms?

Also, see if this fixed it: [6068] -- it's not related to Canonical URLs, but it is related to PATHINFO URLs and "show page on front page"

comment:21 in reply to: ↑ 20 wantmoore7 years ago

Replying to markjaquith:

wantmore,

What are your symptoms?

Also, see if this fixed it: [6068] -- it's not related to Canonical URLs, but it is related to PATHINFO URLs and "show page on front page"

I just updated to r6070 and am still having the infinite redirect problem. With Firefox I get:

The page isn't redirecting properly

      Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
    *   This problem can sometimes be caused by disabling or refusing to accept
          cookies.

It works exactly as expected when I comment out the add_action line in wp-includes/canonical.php

comment:22 follow-up: markjaquith7 years ago

Where is your site?

comment:23 in reply to: ↑ 22 wantmoore7 years ago

The development site is at http://mindstormweb.com/kellyhastings

comment:24 in reply to: ↑ 20 wantmoore7 years ago

I've svn up'd this morning and am still having the issue.

comment:25 markjaquith7 years ago

wantmoore,

Thanks so much for the report. I was able to reproduce the issue, and develop a fix.

comment:26 markjaquith7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [6085]) Always trailingslash the "home" URL. Protect against chained redirects. Thanks wantmoore. fixes #4773

comment:27 jbctech7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This is still broken at revision 6089

jbctech7 years ago

Possible solution

comment:28 jbctech7 years ago

I found the problem. For my site, the Blog Address (URL) in WordPress Options was http://www.MySite.com, however the canonical redirection was redirecting to http://www.mysite.com. The routine that protects against chained redirects did not handle the difference in case.

I have included the diff of what I did to get mine working... you may want to do it here, or you may want to just force it lower in the options menu.

comment:29 markjaquith7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [6097]) Ignore HOST capitalization differences for canonical redirects. props jbctech. fixes #4773

comment:30 Funbug7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Post preview will redirect infinitely on two of my blogs until I add

|| is_preview()

at line 7 of canonical.php

comment:31 Viper007Bond7 years ago

You should probably make a new ticket for this rather than reopening this one.

comment:32 Funbug7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

Okay, sorry. I just wasn't sure -> http://trac.wordpress.org/ticket/5203

Note: See TracTickets for help on using tickets.