I want script will add new rules to current .htaccess
and user no need to ftp or edit it manually.
Example, I use timthumb for resize image on my theme and want rewrite the URL and current .htaccess
will be something like this.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^images/thumb/(.*) timthumb.php?filename=$1
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Question
How to add the new rule to the .htacces
on my theme option.
Enable Mod rewrite for Timthumb? : [Yes] [No]
If click [Yes] RewriteRule ^images/thumb/(.*) timthumb.php?filename=$1
will automatic added to current .htaccess
Let me know
You can add extra rules right after the
^index.php$
line via theWP_Rewrite
class, more specifically theadd_external_rule()
method. They are added to thenon_rewrite_rules
array, which is written in themod_rewrite_rules()
method.This is a very simple example. You should still flush the rewrite rules (once), either on plugin activation or by visiting the Permalinks page.