How do you add mod rewrite directives to rewrite plugin?

Hi there,

I want to know how I can add some lines of code into the roots rewrite plugin, so it automatically adds the Rewrite / Redirect directives to my .htaccess file when wordpress generates a new one.

I’ve manually added some custom RewriteRule and RedirectMatch directives to my .htaccess file, so that it now looks like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^assets/(.*) /app/themes/mytheme/assets/$1 [QSA,L]

RewriteRule ^punk/(.*) /app/scripts/punk/$1 [QSA,L]
RewriteRule ^cheese/(.*) /app/scripts/cheese/$1 [QSA,L]
RewriteRule ^rocket/(.*) /app/scripts/rocket/$1 [QSA,L]
RedirectMatch 301 punk$ /punk/pri1.php
RedirectMatch 301 cheese$ /cheese/bday1.php

RewriteRule ^plugins/(.*) /app/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

I’ve manually inserted 5 lines in the middle of the .htaccess code.

You’ll probably want to reference the wp-h5bp-htaccess plugin and see how it’s adding onto .htaccess instead of looking into how the Roots rewrites plugin adds rules

Sorry for the late reply

1 Like