[wp-hackers] So, this whole .htaccess thing...
Robert Deaton
false.hopes at gmail.com
Sun Aug 27 00:45:04 GMT 2006
On 8/26/06, Jamie Holly <hovercrafter at earthlink.net> wrote:
> > > > (3) Plugins don't have to :)
> > >
> > > Why do they, then? (Example: WP FeedBurner)
>
> > Ask the author. Also a possible lack of proper documentation (also
> > something I may have to volunteer to do).
>
> It could also be pre WP2.0+ plugins (before the rewrite was redone). I have
> notched some out there that work on 2.0, but use the old 1.5 .htaccess
> hacks. That is nothing really up to WP to take care of. The plugin author
> should decide when/if to modify to 2.0.
>
> As far as putting a "router" in the mix, why? To me that is adding one more
> bend in the pipe before the final outcome is produced. You can do a simple
> hook into the rewrite array via a plugin to add urls, or rewrite feed urls
> from other platforms. Simple script to handle Userland style feeds:
>
> <?
> add_filter("rewrite_rules_array", AddUserlandFeed(),1);
>
> function AddUserlandFeed ($rewrite) {
> $new_rules['rss.xml']= 'index.php&feed=rss2';
> return ( $rewrite + $new_rules );
> }
> ?>
>
> Activate plugin then update permalinks and you're done. You can now access
> your feed via http://yourdomain.com/rss.xml It isn't pretty, but it works.
*Almost works. Let me try that again for you.
add_filter('rewrite_rules_array', 'AddUserlandFeed');
function AddUserlandFeed($rewrite) {
$rewrite['rss.xml'] = 'index.php?feed=rss2';
return $rewrite;
}
register_activation_hook(__FILE__, 'UserlandFeedFlushRules');
function UserlandFeedFlushRules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
> Of course depending on the environment your in, some people try to stay
> clear of every plugin they can. For one site I did, I ended up just doing a
> mod_rewrite to handle the old system feeds (this site averages 2-5 million
> feed reads per day). When you consider adding in a plugin and that code
> having to be compiled everytime WP starts (unless you're running opcode
> caching), it makes more sense to let .htaccess handle it.
Actually, as it currently is WP will outperform mod_rewrite with its
internal rewriter (1.5 compared to 2.0). Why? Simple, 99.99% of people
using WP are putting what they want for the old permalinks in
.htaccess. That file must also be parsed on every page load, and a
study has shown that putting rewrites in httpd.conf actually greatly
improves overall performance. Really, it makes sense to let PHP handle
it :).
--
--Robert Deaton
More information about the wp-hackers
mailing list