[wp-hackers] #2740: Include .htaccess in distribution

Owen Winkler ringmaster at midnightcircus.com
Wed May 24 16:11:05 GMT 2006


Kimmo Suominen wrote:
>> Plugins require access to .htaccss that is currently provided via hook. 
>>  If you install .htaccess at the onset and disallow WordPress from 
>> altering it, all of those plugins become broken.
> 
> I'm curious what these plugins do that WP's rewrite processing cannot
> do for them.

Aha!  You've provided your own answer.  See below...

> However, the rules can get hairy when more than one package is using
> virtual URL's (i.e. ones that don't map directly to files).  I only
> have one such package installed currently, but it took me a while to
> figure out how to make it run nicely in a subdirectory with WP in
> the top level directory:
> 
>     RewriteCond %{REQUEST_FILENAME} !-f
>     RewriteCond %{REQUEST_FILENAME} !-d
>     RewriteCond %{REQUEST_URI} !^/(photos)/
>     RewriteRule ^(.+)$ /index.php/$1 [L,QSA]

Regarding the question you posed above about why a plugin would need to 
write to the .htaccess, a plugin could insert this rule in the proper 
place for you.

Note that it would be more efficient to use this .htaccess rule than 
loading the most minimal scripts of WordPress, interpreting the rewrite 
internally, and then attempting to load whatever the originally intended 
target might have been (in this case, it looks like a gallery?).

Using a plugin to add this rule would prevent the rule from being lost 
when you allow WordPress to save new rules.  Without the plugin, 
WordPress would obviously overwrite any manually added rules within the 
WordPress block of rules.

Owen



More information about the wp-hackers mailing list