Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop .htaccess mod_rewrite in a directory

I have copied some code (for Wordpress permalinks) into my .htaccess file in the root directory. All has been working fine. This is the code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

I've now created a new directory that I want to password protect using .htaccess. I've set that up (using a ht.access file in the directory I want to protect) but when I try to browse to the password protected directory I get re-directed to the main sites index.php page.

I'm guessing I need to add something to the .htaccess file in the root directory? Is this correct and if so could someone tell me the code I need to add?

like image 308
Andrew Smart Avatar asked Apr 13 '12 14:04

Andrew Smart


People also ask

What is RewriteEngine on htaccess?

htaccess rewrite rule includes setting a combination of rewrite condition ( RewriteCond ) tests along with a corresponding rule ( RewriteRule ) if the prior conditions pass. In most cases, these rules should be placed at any point after the RewriteEngine on line in the . htaccess file located in the website's docroot.

What is mod_rewrite?

The term "mod_rewrite" refers to a module for the Apache web server, which “rewrites” or redirects requests to specified content. Basically, the module transforms incoming requests to a path in the web server's file system. This makes it possible to "rewrite" a URL.

How do I enable rewrite mod?

Step 1 — Enabling mod_rewrite In order for Apache to understand rewrite rules, we first need to activate mod_rewrite . It's already installed, but it's disabled on a default Apache installation. Use the a2enmod command to enable the module: sudo a2enmod rewrite.


1 Answers

Put this to your password protected subdir .htaccess file.

<IfModule mod_rewrite.c>

#Disable rewriting
RewriteEngine Off

</IfModule>
like image 89
Eddy Freddy Avatar answered Oct 11 '22 06:10

Eddy Freddy