0

After WP upgrade from 3.2.1 to 3.4.1 I faced the problem that rules are not applied same way.

I have the following rule:

(questions-answers)/([mind|nutrition|fitness|beauty]*)[/page/]*(\d*)$

In WP 3.2.1 URL /questions-answers/mid/page/2 matches rule mentioned above, but in 3.4.1 this URL matches different rule: (.?.+?)/page/?([0-9]{1,})/?$.

Any ideas what is wrong and how can I solve the problem?

1 Answer 1

1

I recognize that rule. It's the unusual rule I wrote to deal with the permalink uncertainty issue. :)

First, you'll only get that weird rule if you have your custom permalinks set to start with a non-numeric value. Like, if you have your custom permalink string as just %postname% instead of something like %year%/%postname%.

Next, the special-case rule you're finding isn't added to the top of the list. So if you have your rule being added, then your rule is more specific, and you should be adding it to the top of the rewrite stack so that it gets checked first. You can set the third parameter to add_rewrite_rule to 'top' to do that.

That should solve the issue, really. If it doesn't, well, you'll have to post code so people can see what the problem is.

4
  • Indeed, I use custom permalink: /%category%/%postname%.html (customer requirement) and my special rule is on top (checked with Rewrite analyzer). What part of the code could be useful to see where the pronlem is?
    – Uldis
    Commented Oct 1, 2012 at 9:19
  • I even updated regexp to (questions-answers)/((mind|nutrition|fitness|beauty)/)?(page/([0-9]+))? so now Rewrite analyzer shows that all parts are recognized correctly. Unfortunately this redirects me to category view.
    – Uldis
    Commented Oct 1, 2012 at 9:37
  • If your special rule is on the top of the list, and you're getting something different, then your rule is wrong and not matching your URL. See, the matches happen top to bottom. So if you end up matching a different rule, then that means your rule is wrong somehow.
    – Otto
    Commented Oct 1, 2012 at 9:48
  • How can I output all rewrite rules in order they are apllied to URL?
    – Uldis
    Commented Oct 1, 2012 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.