meyerweb.com

Skip to: site navigation/presentation
Skip to: Thoughts From Eric

Fixing My WordPress Install

Okay, so my “Whole Magilla” feeds—both full-content and summary—are working again, and the main archive page actually shows content.  The problem in both cases, as I mentioned in my previous post, was that WordPress’ code was throwing 404 responses.  In the case of the archive page, it would literally put up a 404 page generated by WordPress, instead of list the most recent posts.  For the Magilla feeds, the RSS files were being served up, but with HTTP 404 headers.  In feed readers that respected HTTP headers, like Firefox or NetNewsWire (and probably most others), that meant the feeds were broken.  Other feeds, such as the tech-only feed, were unbroken, but of course the most popular feeds are the Magilla feeds.

In the end, a post from Alex King showed me the way to a “fix”.  I put that word in quotes because this is really more of a hack.  No, actually, it’s just gross, but it works.  In order to get WP to stop throwing inappropriate 404s, I commented out lines 35 through 135 of classes.php in the WordPress core.  Here’s the beginning and end of the block I commented out:

if (! empty($rewrite)) {
   // If we match a rewrite rule, this will be cleared.
   $error = '404';

[...a ton of redacted lines...]

      $this->did_permalink = false;
   }
}

There you go: with one hundred lines of code commented out, my feeds and archive page work again.  This is not a good idea, but it’s all I could figure out to do.  Obviously, having modified a core file, I’m taking a chance that this won’t cause other problems.  So far I haven’t seen any, but you never know.  I’m also making upgrades much harder on myself, given that the new core file won’t have my modifications.

Similarly, I commented out the mod_rewrite.c block WP added to the end of my .htaccess file, so that I can use my own rewrites and not invoke WP’s rewriting.  With every upgrade, I’ll have to check that file to make sure the block didn’t get added back.

I’m mostly posting this as a reference for anyone who might run into similar problems with their WP 2.x installation.  It’s my hope that a future version of WP will offer some kind of hook or option that will let me easily disable WP’s rewriting and error handling code, since I already have a web server that’s configured to do those things for me.  I don’t mind if it’s a hook that I can address via a plugin as opposed to an option in the preferences, but I’d like to have it.  It would make WP a little more attractive to power users as well, since they’d know that they could do their own rewriting and error handling without having to fight with WP’s internals.

17 Responses»

    • #1
    • Comment
    • Thu 1 Feb 2007
    • 1203
    Keith McLaughlin wrote in to say...

    http://meyerweb.com/eric/thoughts/page/2/ gives a 404 :-)

    • #2
    • Comment
    • Thu 1 Feb 2007
    • 1210
    Eric Meyer wrote in to say...

    Keith: yeah, but that’s really old news, and something I’ve never managed to figure out how to fix. I should just remove the “next/previous” links. Anyway, my point is that the site’s been like that since long before I upgraded to 2.x, so it’s almost certainly not a side effect of my core core file modification.

    • #3
    • Comment
    • Thu 1 Feb 2007
    • 1256
    Nick wrote in to say...

    Why don’t you just change the permissions on your .htaccess so that WordPress can’t edit it?

    • #4
    • Comment
    • Thu 1 Feb 2007
    • 1332
    Eric Meyer wrote in to say...

    Good point, Nick. I’ll look into doing that.

    • #5
    • Comment
    • Thu 1 Feb 2007
    • 1446
    Brad Bice wrote in to say...

    I would also suggest altering the title of this post so that those searching for this problem can more easily find it via a search engine. Maybe a more detailed line such as “WordPress 2.1 404 fix” or something?

    • #6
    • Comment
    • Thu 1 Feb 2007
    • 1723
    Keith McLaughlin wrote in to say...

    The archive search gives an error too btw. Not sure if you knew about that one ;)

    • #7
    • Comment
    • Thu 1 Feb 2007
    • 2235
    Devon wrote in to say...

    And I thought I was having weird problems when I upgraded to 2.1 and it started mangling my raw HTML when it would output a page! Heh. What you have to deal with is just insane. 100+ lines of code commented out …heh. If you don’t have any serious issues, you’ll at least prove there’s a huge code bloat problem in WordPress. Hope all goes well dude.

    • #8
    • Comment
    • Fri 2 Feb 2007
    • 0117
    Mike D. wrote in to say...

    Testing to see if Meyerweb still eats my comments… apologies for the disturbance.

    • #9
    • Comment
    • Fri 2 Feb 2007
    • 0117
    Mike D. wrote in to say...

    Testing again.

    • #10
    • Pingback
    • Fri 2 Feb 2007
    • 0329
    Received from H2-SiteDesign » 404-Probleme in Wordpress 2.1 lösen oder nicht upgraden?

    [...] Tipps zur Bereinigung von 404-Problemen in WordPress 2.1 und fragt sich, ob man upgraden sollte. Fixing my WordPress install by Eric Meyer Okay, so my “Whole Magilla” feeds—both full-content and summary—are working [...]

    • #11
    • Comment
    • Fri 2 Feb 2007
    • 1540
    Eric Meyer wrote in to say...

    Keith: nope, I didn’t know about that one, and that was totally my fault (I failed to keep a template up to date with changes in my plugins). It’s fixed now. Thanks!

    Devon: I don’t believe my commenting proves “bloat”. So far as I can tell, it’s code to handle 404 and related errors. On most sites, that will be welcome, since it’s a rare bird who sets up a blog and then starts editing their .htaccess file. It’s doubtless useful in 99% of cases. I just happen to be in that other 1%.

    Mike: I don’t know why, but Akismet really dislikes your gmail account. Your newsvine.com account post was simply held for moderation since it’d never been used before, but the gmail.com account post got dropped right into the Akismet queue again. I really need to figure out how to put up a warning when that happens, or at least find a plugin that does so. Sorry the spam defenses are being such a pain!

    • #12
    • Comment
    • Fri 2 Feb 2007
    • 2104
    Mike D. wrote in to say...

    Eric: Cool, I just had Matt M. sort me out with some Akismet love… not sure how I ended up on the wrong side of the law. :)

    • #13
    • Comment
    • Sat 17 Feb 2007
    • 2236
    Spike wrote in to say...

    Just caught up with your blog entries. I’ve had a heck of a time installing WP 2.1 for someone else. All related to 404 and 500 server errors as soon as WordPress touched the htaccess. As someone with a flea’s knowledge compared to yours about websites and computers, I hope you’ll consider filing a bug report. Hoping they’ll fix it soon.

    • #14
    • Comment
    • Fri 28 Sep 2007
    • 0309
    B. Beverly wrote in to say...

    I learned basic HTML by reading your pages at CWRU 9 years ago…and you’ve just helped me with a problem that I’ve been bashing my head against the wall about for 8 hours in my job as a full-time designer. Consistency rocks! Thanks.

    • #15
    • Comment
    • Fri 2 Nov 2007
    • 1206
    Jesse Gardner wrote in to say...

    I’d recommend Movable Type 4, but then I bet you get that everywhere you go. ;-)

    • #16
    • Comment
    • Fri 2 Nov 2007
    • 1222
    Eric Meyer wrote in to say...

    I’ve used MT4 and dislike a great deal more than I do WordPress. And before anyone jumps down my throat about that, please (re-)read “Set Preferences“. Thanks.

    • #17
    • Comment
    • Fri 2 Nov 2007
    • 1240
    Carla Hufstedler wrote in to say...

    I had a weird occurrence when I reinstalled WP (aka, returned to) this week–standard MySQL necessities like wp_categories were not created by the install, nor by reinstalling, nor by running upgrade.php. I had to manually hunt down and add the missing tables. So strange.

Leave a Comment

Line and paragraph breaks automatic, e-mail address required but never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Remember to encode character entities if you're posting markup examples! Management reserves the right to edit or remove any comment—especially those that are abusive, irrelevant to the topic at hand, or made by anonymous posters—although honestly, most edits are a matter of fixing mangled markup. Thus the note about encoding your entities. If you're satisfied with what you've written, then go ahead...


February 2007
SMTWTFS
January March
 123
45678910
11121314151617
18192021222324
25262728  

Sidestep

Feeds

Extras