Rewrite Rule Feedback

September 18, 2005

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.

Entry Filed under: WordPress. .

12 Comments Add your own

  • 1. Chris  |  September 18, 2005 at 7:30 am

    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. Chris  |  September 18, 2005 at 7:34 am

    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. Mathias  |  September 18, 2005 at 9:48 am

    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. Trevor  |  September 18, 2005 at 7:25 pm

    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. ryan  |  September 18, 2005 at 7:54 pm

    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. Donncha  |  September 19, 2005 at 8:24 am

    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. Cyndy  |  September 19, 2005 at 3:05 pm

    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. Benedict Eastaugh  |  September 20, 2005 at 5:32 am

    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. Kim @ Neteffects  |  September 28, 2005 at 9:19 am

    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. Mathias  |  September 30, 2005 at 7:38 am

    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. Jani Tarvainen  |  October 5, 2005 at 2:16 am

    I did some performance testing today (http://janit.iki.fi/wp-bench/). Looks like .htaccess rewrite rules are a major drag on performance, but I suppose these new rules can be moved to Apache config :D

  • 12. frankp  |  April 19, 2007 at 9:51 am

    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 Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Archives

Links

Recent Comments

frankp on Rewrite Rule Feedback
Jason on WordPress.com on Twitter
Twittering follow-up… on WordPress.com on Twitter
another wish that wo… on WordPress.com on Twitter
albaran on New Importers

Meta