Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#5760 closed defect (bug) (worksforme)

Infinite redirect loop on archive pages for days/months/years

Reported by: roganty's profile roganty Owned by: markjaquith's profile markjaquith
Milestone: Priority: normal
Severity: normal Version: 2.3.2
Component: Canonical Keywords: canonical, url, date, archive, redirect
Focuses: Cc:


I have canonical redirects disabled due to infinite redirect, but the last major release (2.3) fixed it.

But I have noticed that it is still happening in certain parts of my blog, namely the date archive pages.

For example:
(I have re-enabled the canonical function while this bug is open)

All other pages work fine, except those that show a date archive page

This bug seems similar to #5705

Change History (11)

#1 @roganty
14 years ago

Ok, I've just noticed this, but its also doing it for pages

For example:

#2 @roganty
14 years ago

  • Summary changed from Infinite loop on archive pages for days/months/years to Infinite redirect loop on archive pages for days/months/years

#3 @ryan
14 years ago

  • Owner changed from anonymous to markjaquith

#4 @roganty
14 years ago

I have been doing a little bit of digging around in canonical.php and have found that $requested_url is never the same as $redirect_url

The following bit of code shows some print statements and die() functions that I have added to canonical.php

function redirect_canonical($requested_url=NULL, $do_redirect=true) {
	global $wp_rewrite, $posts, $is_IIS;
print "\r\n<br />".$requested_url." ";
	if ( $redirect_url && $redirect_url != $requested_url ) {
		// var_dump($redirect_url); die();
print "1:".$redirect_url."|".$requested_url." ";
		$redirect_url = apply_filters('redirect_canonical', $redirect_url, $requested_url);
		if ( $do_redirect) {
print "2:".$redirect_url."|".$requested_url." ";
			// protect against chained redirects
			if ( !redirect_canonical($redirect_url, false) ) {
print "3:".$redirect_url."|".$requested_url." ";
				wp_redirect($redirect_url, 301);
			} else {
				return false;
		} else {
			return $redirect_url;
	} else {
print "FALSE ";
		return false;

If I go to /blog/2007/12/ I get the following output:

<br /> 1:| 2:| 

<br /> FALSE3:| Die:1

On any other page I get the following output (followed by the rest of the page):

<br /> FALSE

#5 follow-up: @markjaquith
14 years ago

What's your server setup? Can you set up a phpinfo() page for me to look at?

Also, could you add $_SERVER['REQUEST_URI'] to the list of things echoed in your debug code? Something seems off there.

#6 @roganty
14 years ago

Here is the phpinfo() page for you

And here's the output for $_SERVER['REQUEST_URI'] (on /blog/2007/12/)

On a paged page (/blog/page/2/) the output is:

And on the first page of the blog the output is:

If you need any more details just ask

#7 @roganty
14 years ago

I should explain that my blog is using the verbose rewrite rules as the usual rewrite rules supplied with WordPress don't work

And my permalink structure is /%year%/%monthnum%/%postname%/

A list of PHP variables can be found here

#8 in reply to: ↑ 5 @roganty
14 years ago


Have you been able to do any work on this?
As it has been nearly a week since the last reply.

I have now disabled canonical redirects, as it may soon start to effect my page rank

#9 follow-up: @Denis-de-Bernardy
13 years ago

  • Component changed from General to Canonical

still current?

#10 in reply to: ↑ 9 @roganty
13 years ago

Replying to Denis-de-Bernardy:

still current?

Short answer: I don't know!

Long answer: Since I first reported this I have changed webhosts, and I don't get the problem.
It was something to do with the way that the webserver was setup.

I did discover what was causing the problem, it was something to do with the request_uri variable being the same as a another variable.

It's been a long time and I have since forgotten it!

I assume it's safe to close.

#11 @Denis-de-Bernardy
13 years ago

  • Milestone 2.9 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

let's close, then

Note: See TracTickets for help on using tickets.