Exclude Specific Folder using .htaccess from WordPress Blog





If you have WordPress intalled on your domain’s root directory, you cannot access any other directory on yuor server from front end by typing that directory in your url. Reason for that is WordPress htaccess file catches all http requests and maps them to WordPress index.php file for further processing.

Same is the case with most open source CMS such as Joomla, Drupal etc if you have enabled the url rewriting.

In WordPress, you can exclude one or more directories from being rewritten by adding Rewrite Condition before the rewrite rule in the htaccess file.

Open your WordPress .htaccess file:

Find:
RewriteCond %{REQUEST_FILENAME} !-f
Add after:
RewriteCond %{REQUEST_URI} !^/(folder1|folder2).*$
After modification, your default WordPress .htaccess should look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/(folder1|folder2).*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
# END WordPress
Hope that helps.

Source: http://www.parorrey.com

{ 0 comments... read them below or add one }

Post a Comment