Ulyssesonline

the tech surfer

  • Home
  • About
  • Archives
You are here: Home / General / Exclude Directories From Mod Rewrite

October 19, 2010

Exclude Directories From Mod Rewrite

If you installed WordPress in your root directory, there is a good possibility you may have lost access to other files and directories. WordPress’ rewrite rules may have prevented you from accessing those files. Instead, it’s displaying 404 errors.

To fix this issue, you will need to insert a line of regular expression code in your .htaccess file that will exclude your files and directory from being rewritten.

A typical WordPress .htaccess may look like this.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

Here’s the new .htaccess that will exclude certain directories.

RewriteEngine On
RewriteBase /
<strong>RewriteCond %{REQUEST_URI} !^/(foldername|foldername/.*)$</strong>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteEngine On RewriteBase / <strong>RewriteCond %{REQUEST_URI} !^/(foldername|foldername/.*)$</strong> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]

It’s a simple fix, but it can be frustrating if you don’t know what’s going on.

Filed Under: General, WordPress Tagged With: directory, files, htaccess, regexp, regular expressions, wordpres

Copyright © 2003 - 2018