Exclude folder from htaccess rewrites on WordPress blog

A couple of months ago I tried without success to share some video files on my web domain. I created a new folder, I copied those avi files there but when pointing the browser to that files it gave me that 404 error, page not found.

I took me a while to understand that WordPress especially is rewriting the .htaccess so you no longer can use any other file, except the files accepted by WordPress on your web domain. This is why so many people are installing WordPress blog on a sub-domain or just in another folder and not directly into the root.

When using a CMS (Content Management System) like ModX or WordPress the problem you’re facing is that you’re no longer able to install a second application or to use some sort of files because the rewrites can cause 404 error.

I presented at that time an easy to implement solution for excluding of those desired files from .htaccess rewrite on a WordPress blog:

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

Today I come with a solution for excluding an entire folder from being rewritten in WordPress. The only thing you have to do is adding the following line to the previous block of code:

RewriteCond %{REQUEST_URI} !^/(foldername|foldername/.*)$

To make it work just replace “foldername” with your own that needs to be excluded from the rewrite. Here the entire block oh code you have to implement into your .htaccess files:

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

Hint: I am using WinSCP for accessing my ftp accounts and modify .htaccess files. It’s free and is a very good tool. And, by the way in comparison with others I tried is the only one showing me .htaccess files on the server. Tried before with Total Commander (very handy tool, too) but with no success.

Tags : , ,

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

12 Comments

Leave Comment