WordPress.org

Ready to get started?Download WordPress

Forums

WP1.5 - error with permalinks (4 posts)

  1. bdjohns1
    Member
    Posted 9 years ago #

    I'm having some problems with permalinks since I went to 1.5. My site's over at ben-johsnon.org/blog. Here's how to see the problem:

    Click on the archives for July 2003. Then, scroll down to the iPod/Honda Civic article. Click the post title. 404 error.

    Now, try the same thing in a newer month, say November 2004. Click the post title, and it works.

    I'm running with my permalinks set to /archives/year/month/postid/ (obviously with correct syntax), and I manually cut/pasted the text into my .htaccess file, which resides in the WP root folder.

    Why's this working for newer posts and not older ones?

  2. Michael Adams (mdawaffe)
    Member
    Posted 9 years ago #

    You're getting a 404 for all the posts with a 2 digit post ID. I suspect there's still some remnants of an older rewrite rule that used months or days. Try deleting everything in .htaccess, updating your permalinks (and repasting if .htaccess is not writeable to WordPress).

  3. bdjohns1
    Member
    Posted 9 years ago #

    mda,

    Yep, that appears to be the problem - manually turning a 2-digit post ID into a 3-digit one is working. However, the automatically generated permalinks (ie, the dynamically generated links in post titles in WP itself) are still spitting out 2-digit post IDs. I think this is tripping up some of the rules in .htaccess.

    I just did a little playing around, and I think I can call this a bona-fide bug. WordPress apparently provides default permalinks that are /archives/year/monthnum/day/. This conflicts with my permalink structure, which is /archives/year/monthnum/post_id/ (which is a valid link, as it unambiguously resolves to a single post). WP isn't catching this and the default htaccess rules are overriding mine.

    Looks like I'm going to have to go in and edit the permalink rules that reference 'day' everywhere, or else hack the code to force post IDs to be 3-digit numbers.

    Damn you, WP, for stomping on my link structure! :)

  4. bdjohns1
    Member
    Posted 9 years ago #

    Ok, I've got the workaround - you just need to do the following to make /archives/year/month/post_id permalinks work:

    1) Allow WP to generate a .htaccess.
    2) In that .htaccess file, remove the rewrite rules that take /year/month/day, /year/month/day/feed, /year/month/day/paged. There should be 4 of these rules altogether.
    3) There should be 5 rules left now before the /IfModule tag. In those rules, you should remove one of the paired instances of ([0-9]{1,2})/, then remove &day=$3, and renumber the remaining parameters accordingly.

    You'll end up with the following:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [S=35]
    RewriteRule ^feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1 [QSA,L]
    RewriteRule ^(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1 [QSA,L]
    RewriteRule ^page/?([0-9]{1,})/?$ /blog/index.php?&paged=$1 [QSA,L]
    RewriteRule ^comments/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1&withcomments=1 [QSA,L]
    RewriteRule ^comments/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?&feed=$1&withcomments=1 [QSA,L]
    RewriteRule ^comments/page/?([0-9]{1,})/?$ /blog/index.php?&paged=$1 [QSA,L]
    RewriteRule ^search/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?s=$1&feed=$2 [QSA,L]
    RewriteRule ^search/(.+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?s=$1&feed=$2 [QSA,L]
    RewriteRule ^search/(.+)/page/?([0-9]{1,})/?$ /blog/index.php?s=$1&paged=$2 [QSA,L]
    RewriteRule ^search/(.+)/?$ /blog/index.php?s=$1 [QSA,L]
    RewriteRule ^archives/category/(.+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?category_name=$1&feed=$2 [QSA,L]
    RewriteRule ^archives/category/(.+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?category_name=$1&feed=$2 [QSA,L]
    RewriteRule ^archives/category/(.+)/page/?([0-9]{1,})/?$ /blog/index.php?category_name=$1&paged=$2 [QSA,L]
    RewriteRule ^archives/category/(.+)/?$ /blog/index.php?category_name=$1 [QSA,L]
    RewriteRule ^archives/author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?author_name=$1&feed=$2 [QSA,L]
    RewriteRule ^archives/author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?author_name=$1&feed=$2 [QSA,L]
    RewriteRule ^archives/author/([^/]+)/page/?([0-9]{1,})/?$ /blog/index.php?author_name=$1&paged=$2 [QSA,L]
    RewriteRule ^archives/author/([^/]+)/?$ /blog/index.php?author_name=$1 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&feed=$2 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&feed=$2 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&paged=$2 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/?$ /blog/index.php?year=$1 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&feed=$3 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&monthnum=$2&paged=$3 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/?$ /blog/index.php?year=$1&monthnum=$2 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]+)/feed/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&p=$3&feed=$4 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]+)/(feed|rdf|rss|rss2|atom)/?$ /blog/index.php?year=$1&monthnum=$2&p=$3&feed=$4 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]+)/page/?([0-9]{1,})/?$ /blog/index.php?year=$1&monthnum=$2&p=$3&paged=$4 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]+)/?([0-9]+)?/?$ /blog/index.php?year=$1&monthnum=$2&p=$3&page=$4 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]+)/trackback/?$ /blog/index.php?year=$1&monthnum=$2&p=$3&tb=1 [QSA,L]
    </IfModule>

    Year/month/day permalinks will not work as a result of this change.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags