WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7396 closed defect (bug) (wontfix)

permalink structure /%post_id%-%postname%-%category%-%year%-%monthnum%-%day% returns 404 s only

Reported by: hquadrat Owned by:
Milestone: Priority: high
Severity: blocker Version: 2.6
Component: General Keywords:
Focuses: Cc:

Description

Using this permalink structure

/%post_id%-%postname%-%category%-%year%-%monthnum%-%day%

makes all of the posts end up in WP showing a 404 error. Something major goes wrong with the internal url-rewriting componentent.
The problem has little common with the /index.php-problem in url-rewriting and can not be resolved with any workaround up to date.

Filed this critical because: if this bug only applies to 1% of all WP installations then at the moment there are some million links are being kicked out of google and other SE. SEM and SEO will hate it.

Change History (7)

comment:1 DD326 years ago

It appears to be working fine for me.

Generates URL's like the following:

http://dd32.no-ip.com:8080/wordpress/153-new-site-theme-general-2008-07-04
http://dd32.no-ip.com:8080/wordpress/189-revision-control-prefixes/wordpress-plugin-2008-07-23

(WP_Rewrite dump: http://dd32.id.au/files/wordpress/temp/rewrite.html )

comment:2 hquadrat6 years ago

o.k., then we need to look deeper into the infrastructure, I disabled all plugins to exclude that point. And disabled post revisions with define('WP_POST_REVISIONS', false); in both installs mentioned below but the problem existed before.

It happpens on two sites being hosted on different apache servers: http://www.motorcityblog.de/ and http://www.h-quadrat.com/techblog/ (link structure is a little different).

And for one or more other guys in the forums, here is some more info
http://wordpress.org/support/topic/191423

There is one post at http://www.h-quadrat.com/techblog/ I have written after the update, that one can be read, see here: http://tinyurl.com/6jkvq4

How can I produce that WP_rewrite dump to post it here?

What kind of changes happened with the DB-update form 2.5 to 2.6? I am wondering why the one post mentioned above works?

comment:3 ryan6 years ago

That is a completely evil permalink structure. %postname% and %category% are adjacent and separated by a dash. Dash is a valid character within %postname% and %category%, making the resulting regular expression have to do a ton of backtracking before it throws up it hands for being asked the impossible. Try using "/" instead of "-" as a separator. Or, just use one of the default structures. They are guaranteed to work and be reasonably fast.

comment:4 ryan6 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

comment:5 ryan6 years ago

  • Milestone 2.6.1 deleted

comment:6 hquadrat6 years ago

One way of solving a problem has ever been just saying it's not there :-). For one user it works, for the other not and instead of finding a solution it is declared as not exisiting? Why did it work in 2.5.1. of scratch without any additional work or manipulation? What was changed? And why does it work for other folks even in 2.6. (possible solution see in the end)?

A regex reading out the post-id from those URLs can easily be done

RewriteRule /(\d+)-([-0-9a-z]*) index.php?p=$1 [L]

but I understand it might not be that easy to do it in a generic/abstract way to match all possible combinations a user could choose.

Removing the categories somewhat skipped the issue BUT what can be learned for the future is: when you combine those two placeholders and in case there are similar words in category name and post name serious problems can ocurr. Yes, agreed. But it's not generally evil, it's far away from that.

One measure against the regex failing for the above case would be: let it stop at the first occurrence of whatever end-criteria for a category or post name and not letting it go till the last appearance (regex not being 'greedy') - that is one behaviour discussed with regex more or less often.

And this regex behaviour must have been regareded AND implemented in WP 2.5.1 because otherwise the links would have failed before.

comment:7 ryan6 years ago

The only permalink related change between 2.5.1 and 2.6 involves permalink structures with index.php in them. If you have such a structure, you could be experiencing #7306. But your example does not have index.php in it. Greedy permalinks such as yours are notoriously problematic. I advise people to never use %category% in their permalink structures. The "Custom Structure" field in the Permalinks Settings should probably be accompanied by a big "Use at your own risk" warning.

Note: See TracTickets for help on using tickets.