Fixing My WordPress Install
Published 17 years, 9 months pastOkay, 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.
Comments (17)
http://meyerweb.com/eric/thoughts/page/2/ gives a 404 :-)
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.
Why don’t you just change the permissions on your .htaccess so that WordPress can’t edit it?
Good point, Nick. I’ll look into doing that.
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?
The archive search gives an error too btw. Not sure if you knew about that one ;)
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.
Testing to see if Meyerweb still eats my comments… apologies for the disturbance.
Testing again.
Pingback ::
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 […]
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!
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. :)
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.
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.
I’d recommend Movable Type 4, but then I bet you get that everywhere you go. ;-)
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.
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.