#5089 closed defect (bug) (fixed)
Canonical Redirect causes continual 301 redirect loop
Reported by: | wcraigtrader | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 2.7 | Priority: | highest omg bbq |
Severity: | critical | Version: | 2.5.1 |
Component: | Permalinks | Keywords: | redirect |
Focuses: | Cc: |
Description
I have a somewhat convoluted setup that works fine with WordPress 2.2, but is broken horribly by WordPress 2.3's Canonical Redirect feature.
I have two webservers: an external Apache instance that serves multiple domains, but for most domains it's really a reverse proxy to an internal webserver. The internal webserver hosts multiple sites, and in particular, several WordPress instances. The internal sites don't have anything fancy in their .htaccess files; the external webserver ensures that requests to non-canonical domains are redirected correctly.
When I upgraded one of my sites (http://ludus.unicornsrest.org/) to WordPress 2.3, access to the front page (but not the admin pages) was broken: it gets a continual 301 redirect to http://ludus.unicornsrest.org/. Here are the headers from curl:
curl -I -L http://ludus.unicornsrest.org/ HTTP/1.1 301 Moved Permanently Date: Thu, 27 Sep 2007 05:35:54 GMT Server: Apache/2.0.59 (CentOS) X-Powered-By: PHP/5.1.6 Set-Cookie: PHPSESSID=9vnpn1t6o7b4kbrsk56fn5tgp1; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Pingback: http://ludus.unicornsrest.org/xmlrpc.php Location: http://ludus.unicornsrest.org/ Content-Type: text/html; charset=UTF-8 Connection: close HTTP/1.1 301 Moved Permanently Date: Thu, 27 Sep 2007 05:35:55 GMT Server: Apache/2.0.59 (CentOS) X-Powered-By: PHP/5.1.6 Set-Cookie: PHPSESSID=j9tl0rjulelhop34ji2ioj9ep5; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Pingback: http://ludus.unicornsrest.org/xmlrpc.php Location: http://ludus.unicornsrest.org/ Content-Type: text/html; charset=UTF-8 Connection: close HTTP/1.1 301 Moved Permanently Date: Thu, 27 Sep 2007 05:35:55 GMT Server: Apache/2.0.59 (CentOS) X-Powered-By: PHP/5.1.6 Set-Cookie: PHPSESSID=5pmfi1go1o18biabb0to7ttro5; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache X-Pingback: http://ludus.unicornsrest.org/xmlrpc.php Location: http://ludus.unicornsrest.org/ Content-Type: text/html; charset=UTF-8 Connection: close
I had to download and activate Mark's plugin to disable canonical redirects.
My WordPress and Blog Addresses are set to http://ludus.unicornsrest.org
.
I looked (briefly) at the redirect_canonical function, but there's too much going on in there for me to determine what the actual problem is. I looked at #5017, but that ticket doesn't provide any insight into my problem.
Is there any way that one of the WP developers could put together a simple page that would dump all of the appropriate variables that redirect_canonical depends upon, that I could load into my site to give you the data you need to see what's going on? No offense, but I don't give *anyone* access to the internal server.
Change History (17)
#2
@
17 years ago
Yes, I think it will be a problem, because you can't access the internal server externally, right? So, if you test the blog externally, one page might work, but hyperlinks will probably be broken, which is what I'm seeing now at http://ludus.unicornsrest.org/, as permalinks are linking to ludus.unicornsrest, not ludus.unicornsrest.org.
#3
@
17 years ago
Yeah, I just caught it when the RSS feed updated and all of the published links broke. Now I've reverted to the original configuration, and re-enabled the disable canonical redirects plugin. Frell.
Any chance that you'll add a configuration setting for disabling canonical redirects, so I don't need a plugin?
#4
@
17 years ago
Ideally, the canonical redirects feature should work perfectly, and not interfere with anything. It is based on this philosophy that we cannot justify adding an option for it -- better to fix the feature instead.
#5
@
17 years ago
- Owner changed from anonymous to markjaquith
Assigning to Mark as this stuff is his baby.
#7
in reply to:
↑ description
@
17 years ago
here's my solution:
external interface server: change /etc/hosts: give ludus.unicornsrest.org internal ip
external interface apache: proxy to http://ludus.unicornsrest.org/ (instead of internal ip)
internal webserver: should work as is.
#8
@
17 years ago
I tried this, and it almost worked -- you missed a step:
- External /etc/hosts :: Add <<Internal IP>> <<External Name>>
- External httpd.conf :: Change ProxyPass / ProxyPassReverse to <<Internal Name>>
- Internal httpd.conf :: Add <<External Name>> to ServerAlias list
That said, I really don't like this solution because it needs to be done for every hosted website AND it's harder to debug. For example, if I'm sitting on the external host, trying to debug the redirection (eg: with curl), the curl options go from
curl -v -I http://ludus.unicornsrest.org/
to
curl -v -I -H 'Server: ludus.unicornsrest.org' http://localhost/
AND it still doesn't work because in this case the external Apache doesn't seem to redirect to the right address (I think it's dropping the Server: header).
I think at this point that it's still a bug in the Canonical Redirect filter (since all it needs to do to break the redirect loop is recognize when it generates the same URL as it was originally passed and do nothing) and leave it disabled.
Thanks for your help; let me know when you fix the bug.
#9
@
17 years ago
yeah extra step in 3 is necessary only when you have virtual host conf in internal apache. and yeah, this is _only_ a temporary workaround for the time being now.
#10
@
17 years ago
Just encountered this issue on a stock standard Yahoo! Web Hosting setup. Required Mark's plugin to make the blog usable.
#11
@
17 years ago
This issue struck me today, too.
I use a Rewrite Rule (Rewrite Rule (.*)$ http://www.host2.com/foo/$1 [P,L]) on server1 to be able to work with the domain name although wordpress is hosted on server2.
With canonical.php active, wordpress gets the call but redirects to http://www.host2.com/foo/foo/.
#12
@
17 years ago
I am having the same problem after updating to 2.3 on my blog: volksvegan.org (the domain is set to go to a folder on my main domain name on my hosting account - meganpru.com/volksvegan/). I was able to edit my settings a second ago, all of the sudden I get stuck in a redirect loop, even when trying to go to my wp-admin page. The address bar keeps going between volksvegan.org and meganpru.com/volksvegan over and over again as well.
Here's the error message:
Too many redirects occurred trying to open “http://volksvegan.org/volksvegan/?redirect_to=%25252525252525252Fvolksvegan%25252525252525252Fwp-admin%25252525252525252F”. 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 was just able to post a new post, and when I tried to change my time zone settings, suddenly I got the error. I'm not all that wordpress-savvy yet, so I'm not sure what I need to do to fix this. It seems to be a common error so I would hope WordPress would fix this!
Please let me know if I should start my own ticket for this... I'm new to this forum... Thanks!
#13
@
16 years ago
Was this bug ever fixed? I am using WordPress 2.5.1 & Apache server in XAMPP for Mac OS X.
I have my WordPress address set to be http://localhost/mywordpress & my blog address set to be http://wordpress.local.
In my /private/etc/hosts file I have: 127.0.0.1 wordpress.local.
In my /Applications/xampp/etc/httpd.conf I have:
Alias /mywordpress "/Users/edonovan/Sites/mywordpress"
<Directory "/Users/edonovan/Sites/mywordpress">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Finally in my /Applications/xampp/etc/extra/httpd-vhosts.conf I have:
<VirtualHost *:80>
ServerAdmin outofegypt@…
DocumentRoot "/Users/edonovan/Sites/mywordpress"
ServerName wordpress.local
ErrorLog "logs/wp-error_log"
CustomLog "logs/wp-error_log" common
</VirtualHost>
I have to set the blog address to http://wordpress.local or else wget -S shows me that I get a redirect from http://wordpress.local to http://localhost.
#14
@
16 years ago
- Milestone changed from 2.9 to 2.7
- Priority changed from normal to highest omg bbq
- Severity changed from major to critical
- Version changed from 2.3 to 2.5.1
The problem still exists, for anyone else who comes across this. Version 2.6.x
Login will loop forever unless your define wp_siteurl as an internal address, which then makes all your links redirect and break.
Running on Windows ENT Server / IIS
I decided to play around with this some more, went out on a limb and changed the Blog Address in the options to match the internal server virtual host name, and all of a sudden it works. You might want to update the documentation to more clearly describe the intent and differences between the WordPress address and the Blog address...
Previously the posts' guid (for pages) included the external site name; now it includes the internal site name. Will this be a problem going forward?