Opened 3 years ago
Last modified 18 months ago
#12405 new enhancement
Query String based Permalinks
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Permalinks | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | mike@…, mikeschinkel@… |
Description
Here's a 80% working patch to implement query string based permalinks (/?%year%/%monthnum%/%postname%/) mentioned in #12404.
Try
- http://example.com/ (home URL)
- http://example.com/?nothing (query string with args that don't have anything to do with the permalink structure)
- http://example.com/?2010/02/hello-world/ (a post)
I'm not sure if this is the best implementation. It's also hacked together (fixing the $matches on the fly instead of generating the real rewrite rules, for example). Call it a proof of concept.
Canonical redirects don't work correctly when using query string permalinks with this patch (?p=1 doesn't redirect).
Attachments (2)
Change History (10)
- Cc mike@… added
It looks like this was posted before Google's "crawlable AJAX" proposal had gotten much traffic, http://googlewebmastercentral.blogspot.com/2009/10/proposal-for-making-ajax-crawlable.html.
That presented the idea of a URL hash-bang, like Twitter uses now: twitter.com/#!/username. I think these are a better idea than using querystrings, since Google went live with hash-bangs but still suggests that querystring pages limit their parameters (here, http://www.google.com/support/webmasters/bin/answer.py?answer=35769&hl=en#1)
Basically, the original suggestion:
- /?%year%/%monthnum%/%postname%/
...might be better as:
- /#!/%year%/%monthnum%/%postname%/
(The preceding slash is my own preference. In the event the querystring is used, I think it should stay [like "/?/$year%..."] The added slash would make an explicitly matchable pattern [the "?/"] & make it easy for default querystring permalinks to be preserved.)
Hashbangs are terrible. I'd probably go on strike if we introduced these, and I bet MarkJaquith would walk out with me. :-)
For more, see http://www.tbray.org/ongoing/When/201x/2011/02/09/Hash-Blecch and http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs.
Twitter would have launched using HTML5 History if it were not for a webkit bug. See http://www.adequatelygood.com/2011/2/Thoughts-on-the-Hashbang, https://bugs.webkit.org/show_bug.cgi?id=42940.
comment:3
in reply to:
↑ 2
mikeschinkel — 18 months ago
- Cc mikeschinkel@… added
Replying to nacin:
Hashbangs are terrible. I'd probably go on strike if we introduced these, and I bet MarkJaquith would walk out with me. :-)
Totally agree! if either of this ideas went mainstream in WP I'd probably switch back to Drupal, and by now I hate Drupal.
Or just fork WP...
Good points @nacin, I hadn't considered how fragile this might be. Also, one your links shows the hashbang is un-crawlable by anyone except Google, and that's really a bad idea (from: http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs):
"All non-browser user-agents (crawlers, aggregators, spiders, indexers) that completely support both HTTP/1.1 and the URL specification (RFC 2396, for example) cannot crawl any Lifehacker or Gawker content. Except Googlebot."
Mike, what do you mean by "either of these ideas"? Obviously the hashbangs, but do you dislike query string permalinks in-general or my minor suggestion on preceding slash?
comment:5
in reply to:
↑ 4
mikeschinkel — 18 months ago
Replying to mbijon:
Mike, what do you mean by "either of these ideas"? Obviously the hashbangs, but do you dislike query string permalinks in-general or my minor suggestion on preceding slash?
All of it. I'd really hate to see any movement away from standard permalinks for many reasons.
Reasons:
- The inclusion of a question mark makes URLs more cryptic and makes less technical people discount them as being understandable.
- It makes them longer and more characters to type. http://example.com/foo/ vs. http://example.com/?/foo/
- It gives people less reason to actually fix their permalinks.
- Worst of all, given that WordPress addresses 65 millions sites, it sets a precedent just like Twitter did. People who don't think through the ramifications think "Oh, that's now the cool way to build websites" and they mimic it. With great power comes great responsibility.
Much better IMO to put a big Akismet style notice that says:
"YOU REALLY NEED TO CHANGE YOUR PERMALINKS, OR GOOGLE WILL FORESAKE YOU.
HERE'S HOW!"
I also think if we put our heads together we could come up with a better way to enable hosts to make this work. But that's a much longer discussion that I doubt anyone wants to tackle this close to 3.3 release...
Anyway, in general I really dislike ideology or zealotry, but I'll admit to being an ideologue and a zealot when it comes to URLs...
Mike, I understand your objection now. My understanding of this ticket is different.
I thought this was only to change non-redirect permalinks from "?id=123" into some form of "?friendly-worded-title". In the event a user doesn't have mod_rewrite/.htaccess (and *only* then) I think the form of links suggested here are better than "?id=123".
What are your thoughts of the suggestion in this ticket being enabled only for that sub-set of users?
Details & Related:
Query string containing permalinks are the defaults now. It's likely that everyone who can change them does so immediately after setting up WP (see the discussion of that here, #16416). Unless we can do perfect mod-rewrite detection things should stay that way -- which is where I thought this tasks "better defaults" came into play.
This should stay "Future Release". I had just added a semi-related bug and dragged-up a few non-3.3 tickets that I thought were related to mine, #18841
comment:7
in reply to:
↑ 6
mikeschinkel — 18 months ago
Replying to mbijon:
Mike, I understand your objection now. My understanding of this ticket is different.
I thought this was only to change non-redirect permalinks from "?id=123" into some form of "?friendly-worded-title". In the event a user doesn't have mod_rewrite/.htaccess (and *only* then) I think the form of links suggested here are better than "?id=123".
Doing that will IMO cause many fewer people to go to the trouble to set URLs that don't require the '?'. I'd rather see us encourage people to fix them, encourage web hosts to make it easier, etc. than to give people a crutch that many would consider "good enough." Just my opinion, of course.
Query string containing permalinks are the defaults now. It's likely that everyone who can change them does so immediately after setting up WP (see the discussion of that here, #16416). Unless we can do perfect mod-rewrite detection things should stay that way
Exactly.

First patch was missing a file.