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
This is the #1 google result and the wrong answer.
The correct answer is adding this before the Wordpress directives.
It's worth noting that it matters where in the flow of the .htaccess this line goes.
See here : http://tanyanam.com/technology/wordpress-exclude-directory-from-url-rewrite-with-htaccess - the line needs to come before the WordPress ones, it won't work after them.
Rob
If you’re using mod_rewrite in a .htaccess file, you just need to specify the URL path without the local path prefix in your patterns. In your case without the leading
/
(as you’re in the document root/
):you could add something like this:
but this should not be needed, because if csNewsAd indeed is a directory (folder) it should not be rewritten in the first place because of
are you sure there isn't anything else sitting between you and that folder, rights or (indeed) another .htaccess?
I have GoDaddy hosting, and this issue killed me. I had the same issues over and over again with conflicting .htaccess options in public_html, with my password-protected sub-directory.
I ended up buying another account because I tried about a million different modifications to my .htaccess file, and nothind worked around this problem. I'm sharing my setup and solution, now, just for completeness and clarity. (Just so you know, the account was worth it anyway, so no biggie.)
If it looks like a combination of other's answers, that's because it is. It took ALL of that to work.
Directory structure:
The subfolder .htaccess has password the protect feature, so similar to this:
The public_html .htaccess originally had this, and it wasn't working (in that it swallowed EVERYTHING and redirected it, so that FatFreeFramework or CodeIgniter was handling it):
In order to fix this problem, I added two lines to my public_html .htaccess file. And so you're not guessing as to where, I'll show the whole file again:
So, that's my story. It works now. Thank you to Jory and GmonC!!! I upvoted you guys.
You should try this one