Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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 
like image 823
Joel A. Villarreal Bertoldi Avatar asked Feb 23 '10 23:02

Joel A. Villarreal Bertoldi


People also ask

What is .htaccess used for?

The . htaccess file provides a way to make configuration changes to your website on a per-directory basis. The file is created in a specific directory that contains one or more configuration directives that are applied to that directory and its subdirectories. In shared hosting, you will need to use a .

Do I need a .htaccess file?

htaccess is not required for having a general website. That file simply allows you to make changes in the way your website behaves for example banning people from accessing your site or redirecting an old dead link to a new page. Some software like Wordpress requires settings in the . htaccess file (or httpd.

What is htaccess code?

Htaccess (HyperText Access) is a simple configuration file that allows designers, developers and programmers alike to alter the configuration of the Apache Web Server in order to provide additional functionality.

Where is the .htaccess file Apache?

htaccess file can be found at /opt/bitnami/APPNAME/. htaccess. Some applications do not have the /opt/bitnami/apache2/conf/vhosts/htaccess/APPNAME-htaccess.


2 Answers

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

instead of

RewriteRule ^/csNewsAd($|/) - [L]  
like image 88
GmonC Avatar answered Sep 28 '22 16:09

GmonC


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.

like image 44
Jory Hogeveen Avatar answered Sep 28 '22 16:09

Jory Hogeveen