Rewrite Rule Feedback

How are the new rewrite rules in 1.6 working for everyone? We’ve been running with them for months now and haven’t received any bugs about them for some time.

1.6 adds a minimal set of rewrite rules to htaccess. These rules pass on the rewrite duty to WP itself. Here’s an example of what they look like:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php

This is a nice, compact set of rules that has the advantage of not requiring updates whenever a page is added. htaccess needs to be writable only when it is first populated.  WordPress handles rewrite and 404 duties.

12 thoughts on “Rewrite Rule Feedback

  1. The rules are working out well for me so far. Have yet to notice any issues. I’m no rewrite expert, so I’m a bit curious as to what exactly the conditionals are checking.

  2. I’ve noticed one minor issue with permalinks, which may or may not be related to the 1.6 .htaccess rules.

    My permalink structure does not include a trailing slash on the slug. However if the slash is present, WP goes ahead and responds with the entry. I believe it would be more correct to 404 or redirect these to the proper permalink (sans-slash in my case). Maybe there’s been discussion on this before?

  3. How about adding ErrorDocument 404 /index.php?error=404 to the .htaccess? That way, not exclusively in-WP 404 errors would be displayed through the 404 template…

  4. Also, I was wondering if the .htaccess file with these rules will be included in the download – then you wouldn’t really need to have the file be writable at all…?

  5. We still have to dynamically set paths such as the RewriteBase. Also, we’ve been folllowing the rule that WP does not own htaccess. We insert our rules and try not to stomp on what’s already there.

  6. I gotta experiment with MU to see if I can let WP handle most rewrites. Unfortunately the URL doesn’t often match the directory structure so it’s not possible to have it as minimalistic as yours above but I’d like to cut it down as much as possible!

  7. Are the new rewrite rules going to implement the same functionality of the two permalink plugins that are out? Or at least the one that fixes the trailing slash?

  8. Great to see you’re cleaning up the Rewrite Rules. I have a bunch of redirects on my site (having moved or removed various things), but WordPress keeps eating the things I add to the .htaccess. One possibility is to deny it access through CHMOD, and just update it myself, but this is work I’d really rather avoid.

    The question: does WordPress simply generate a new .htaccess when it changes a rule, and copy it over the old one? Is there some way to add stuff to the .htaccess file that WordPress won’t remove? One possibility, I suppose, would be to have a “custom .htaccess rules” section on the Dashboard; are there any plugins to help with this?

  9. Same problem for me really, I try to redirect a page every time its moved, but is really hard with the last system for .htaccess.

    But WordPress is still a fantastic publishing system!

  10. Also, we’ve been folllowing the rule that WP does not own htaccess. We insert our rules and try not to stomp on what’s already there.

    Of course. But can you think of one situation in which the user wouldn’t want to use the 404 error template for every 404 error inside the WP root dir?

    I say add the feckin’ thing.

    ErrorDocument 404 /index.php?error=404

  11. I’ve been experiencing something similar to Benedict (no.8), where custom rules I add get seemingly removed by WordPress…

    Is there a way around this?

    It’s odd because I don’t remember doing anything that would have caused WP to rewrite the htaccess, but one day I realised my additions were gone…

Leave a Reply