WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#3451 closed defect (bug) (fixed)

Page URI canonization

Reported by: pah2 Owned by: markjaquith
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: Permalinks Keywords: needs-patch permalink slug canonization
Focuses: Cc:

Description

The nice permalink URIs for posts or categories are case-insensitive, but the page URIs are not.

e.g. http://matt.wordpress.com/about/
cannot be reached via
http://matt.wordpress.com/About/

This results in 404s being returned when a user incorrectly gets the case of the URI wrong. This is particularly a problem for weblogs that have migrated old pages to WordPress, and have external pages pointing to them with varying case applied to the URIs.

Attachments (1)

3451.canonical.redirect-pages.diff (2.2 KB) - added by DD32 6 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 markjaquith7 years ago

  • Keywords needs-patch added
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned
  • Version set to 2.1

For 2.2, I'd like to have some form of automatic URL correction in core... so if you're using http://example.com/about/ and someone puts in http://example.com/About/ or http://www.example.com/about/ or http://example.com/About/ or http://example.com/?page_id=2 or any number of "close, but not quite" URLs, it'll 301 to the real URL. That's good for search engine juice!

comment:2 Viper007Bond7 years ago

For the record, page ID & lack of trailing slash (which we should also address) is currently accomplished via a great plugin which I use.

Examples:

http://www.viper007bond.com/about

http://www.viper007bond.com/?page_id=43

However, if we put something like this into the core, it needs a filter or a hook. That plugin currently has exclusion regex which is super helpful.

For example, this is my permalink structure:

http://www.viper007bond.com/archives/2006/12/01/blog-upgraded/

I cheat and have a page located at http://www.viper007bond.com/archives/. With the current code, you can't do that without breaking all your post permalinks (at least in 2.0.x it did). I accomplished it via a custom mod_rewrite rule in my .htaccess that loads up index.php/post-archives/.

comment:3 foolswisdom7 years ago

  • Milestone changed from 2.2 to 2.3

comment:4 markjaquith7 years ago

  • Milestone changed from 2.3 to 2.4 (next)

Not handled by current canonical redirect code, but it's too late to start working on it.

comment:5 DD326 years ago

Should the Canonical redirect redirect it in this case, Or should the page matches be done case insensitivly?

Do search engines treat different capitalised urls as seperate? (thinking double content here)

comment:6 Viper007Bond6 years ago

My vote goes for redirect to whatever the user entered for the stub. On Linux, you could have a site.com/file.php and a site.com/File.php and those would be two different scripts.

comment:7 DD326 years ago

the canonical code redirects ?page_id=43 to the correct page allready.

I've just made a patch up which attempts to redirect pages, However, it may be too greedy for the likes of some.

Lets say i have a page structure like this:

Sub-marine
About Me 
   Sub about me 
      sub-sub about me

The attached patch will redirect:

hostname/wordpress/abOUT-me/ => hostname/wordpress/about-me/
hostname/wordpress/abOUT-me/sub- => hostname/wordpress/about-me/sub-about-me/
hostname/wordpress/abOUT-me/sub-sub => hostname/wordpress/about-me/sub-about-me/sub-sub-about-me/
hostname/wordpress/sub- => hostname/wordpress/sub-marine/
hostname/wordpress/sub-sub => hostname/wordpress/about-me/sub-about-me/sub-sub-about-me/

Now, getting to the greedy part:
It also has the effect of redirecting things like:

hostname/wordpress/a => hostname/wordpress/about-me/
hostname/wordpress/su => hostname/wordpress/sub-marine/
hostname/wordpress/hta => hostname/wordpress/2007/11/05/htaccess/

In the case where there's multiple destinations possible, It selects the uppermost item alphabetically.
So hostname/wordpress/a will choose 'about-me' over 'azzes', and 'about-me' over 'parent/aaaa-sub-page'

If it comes accross a semi-permalink:
hostname/wordpress/perma/structure/post-na it'll still redirect it to that post: hostname/wordpress/perma/structure/post-name/ rather than sending it to hostname/wordpress/post-nam/

comment:8 follow-up: Viper007Bond6 years ago

Another possible solution for multiple destinations possible is to pull up the search template and list out all the post/pages for the user to pick from.

comment:9 in reply to: ↑ 8 DD326 years ago

Replying to Viper007Bond:

Another possible solution for multiple destinations possible is to pull up the search template and list out all the post/pages for the user to pick from.

Thats a much nicer option IMO.

The present redirect code(in trunk) just redirects it to the first item it comes accross(unordered) that fits the criteria that its managed to find. On second thoughts, that $order statement could probably be hard coded for the query if its to select only one item.

comment:10 djr6 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

comment:11 janbrasna5 years ago

  • Cc janbrasna added
  • Component changed from General to Permalinks
  • Milestone changed from 2.9 to 2.8
  • Summary changed from Page URIs are case-sensitive to Page URI canonization

Changing Summary since a) the original issue is no longer present in trunk (however it's not canonized, sic) and b) the comments lean towards a different issue - the canonization itself.

Please see revert [9649] and respective #6627 that caused some regression.

comment:12 janbrasna5 years ago

  • Keywords permalink slug canonization added

comment:13 DD325 years ago

See also: #7577 ( Make sure URLs are all lowercase )

comment:14 Denis-de-Bernardy5 years ago

  • Milestone changed from 2.8 to Future Release

One day, we'll need to compile a huge ticket with all of the permalink problems...

comment:17 Denis-de-Bernardy5 years ago

  • Keywords needs-patch added; has-patch needs-testing removed

comment:18 Denis-de-Bernardy5 years ago

  • Milestone changed from Future Release to 2.9

comment:19 hakre5 years ago

  • Milestone 2.9 deleted
  • Resolution set to fixed
  • Status changed from accepted to closed

Not an issue any longer as reported. Will close as fixed. Anyway, as long as pplz are acutally getting a 404 this is not a bug.

Note: See TracTickets for help on using tickets.