.htaccess & WordPress: Exclude folder from RewriteRule

I have this .htaccess file in WordPress. It's located at /public_html/ (web root). I need to exclude a folder (csNewsAd) from the rewrite engine. I've tried this, based from another question similar here at SO, but didn't work at all.

AddHandler x-httpd-php5 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/csNewsAd($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Any suggestions?

More data

There's another .htaccess inside /csNewsAd for password protection:


AuthName "Clasificados"
AuthType "basic"
AuthUserFile /home/ig000192/public_html/csNewsAd/.passwd
Require valid-user

Solution 1:

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

instead of

RewriteRule ^/csNewsAd($|/) - [L] 

Solution 2:

Place the line below in the .htaccess file in the root.

ErrorDocument 401 default

Had the exact same problem and this worked for me. It is not the problem that the redirects don't work. The problem is that the 401 (Authorization Required) error is nog defined so the "popup" doesn't show.

Solution 3:

This is the #1 google result and the wrong answer.

The correct answer is adding this before the Wordpress directives.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.*)$ [OR]
    RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.*)$ [OR]
    RewriteRule ^.*$ - [L]
</IfModule>

Solution 4:

Was having the same issue and found the answer to my problem here: http://kb.siteground.com/article/How_to_exclude_a_folder_from_Wordpress_permalinks.html

--From the site

To exclude the subfolders from the WordPress rewrite rules, you need to edit the .htaccess file and change the bold line below:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L] # Original line
RewriteRule ./ /index.php [L] # New line
</IfModule>
# END WordPress

Solution 5:

.htaccess affects all directories underneath, so if you put an .htaccess in csNewsAd with the rewrite directives you want, it will take precedence over the root file.