Canonical redirect of feed URLs with suffixes is wrong
|Reported by:||jhodgdon||Owned by:||markjaquith|
As of  and the 2.7 release, if for some reason I have a URL like
then the redirect in wp-includes/canonical.php function redirect_canonical() redirects this to
and that URL 404s.
The reason this happens is that the redirect_canonical() function, when it is dealing with feed-related URLs:
- strips off /feed/ only from the end of the URL
- checks is_feed() (which returns true if /feed/ is in the URL anywhere)
- if is_feed() is true, it assumes /feed/ has been completely stripped from the URL (which it hasn't if the /feed/ is not at the end), and adds /feed/ to the end of the URL.
The patch I am about to add to this report additionally strips /feed/ off the middle of the URL, which at least makes the redirect work for me -- then it redirects to
which works just fine.
By the way, there are some other places in the WP code where this assumption has been made, that certain things are always coming in at the end of URLs and not in the middle -- I have run into this before in previous WP versions and gotten around it with annoying shenanigans in my plugin that adds suffixes to URLs (among other functionality). Some of these issues are elsewhere in that same canonical_redirect() function, and some are in the rewrite logic (especially the parts of both having to do with paging). So if you feel ambitious, you might want to search these out and fix them. If not, I'd appreciate it if you could at least put this patch into the 2.7.1 release.
Change History (8)
- Component changed from General to Canonical
- Owner changed from anonymous to markjaquith