Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#7396 closed defect (bug) (wontfix)

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

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


Using this permalink structure


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)

#1 @DD32
14 years ago

It appears to be working fine for me.

Generates URL's like the following:

(WP_Rewrite dump: )

#2 @hquadrat
14 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: and (link structure is a little different).

And for one or more other guys in the forums, here is some more info

There is one post at I have written after the update, that one can be read, see here:

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?

#3 @ryan
14 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.

#4 @ryan
14 years ago

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

#5 @ryan
14 years ago

  • Milestone 2.6.1 deleted

#6 @hquadrat
14 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.

#7 @ryan
14 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.