The permalink mod_rewrite code isn't always right (2 posts)

  1. pkhuong
    Posted 11 years ago #

    The generation of the mod_rewrite code is a really neat feature. Unfortunately, the outputted regex isn't always right for the view by date. If i have
    for the virtual structure, the regex is right:
    RewriteRule ^archive/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([0-9]+)?/?([_0-9a-z-]+)?/?([0-9]+)?/?$ /wp/index.php?year=$1&monthnum=$2&day=$3&p=$4&name=$5&page=$6 [QSA]
    However, if i change that to
    (note the dash between post_id and postname), the dash isn't marked as optional. IE, i get:
    RewriteRule ^archive/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/?([0-9]+)?-([_0-9a-z-]+)?/?([0-9]+)?/?$ /wp/index.php?year=$1&monthnum=$2&day=$3&p=$4&name=$5&page=$6 [QSA]
    The bug is there: "/?([0-9]+)?-([_0-9a-z-]+)?" The dash is now absolutely needed for a match. I'm not sure how the regex should be arranged in such cases, so i've reverted to slashes there too. I _believe_ marking the - as optional ("-?") would be enough, and not cause problems with dashes in article names, but i'm not sure.
    Still, WP is a great system! I love how easy it is to adjust it to do exactly what i want. Even when there isn't an explicit hook, the code is simple enough that it's not too hard to adapt it ^_^

  2. Ryan Boren
    WordPress Dev
    Posted 11 years ago #

    Already fixed in 1.3.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.