If you need to get redirects, or other htacccess directives, working in subdirectories under the WordPress installation, this may help.
So let’s say, for example, you have a WordPress install at /blog/ and you create a directory at /blog/customstuff/, and edit a new /blog/customstuff/.htaccess file. The following redirects all requests (that don’t exist) to index.php.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?request=$1 [NC,L]
But wait, it doesn’t work? Looks like it should? That’s what I thought too.
The problem is that the /blog/.htaccess file that WordPress set up has a RewriteBase directive, which is being inherited in our new /blog/customstuff/.htaccess file. Knowing that, the fix is simple — redefine RewriteBase…
RewriteBase /blog/customstuff/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?request=$1 [NC,L]
Method 2:
If that doesn’t work, you can always try adding an “exception” to the WordPress .htaccess file.
Replace
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
With:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !^blog/customstuff