如何在htaccess中排除特定文件夹

When user hits

this link my htaccess is working.

But when user hits

my website redirect to

because my website contains folder2 in my directory structure.

When user hits

my htaccess should ignore this URL because I want to redirect user to index.php which present in folder2

The code written below is present in my htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

What should I do? Please help me out from this problem.

Lets say you want to exclude the folder 'exclude_me' . Adding

RewriteCond %{REQUEST_URI} !^/exclude_me/.*$

does the trick for me

Try this:

RewriteEngine On

RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI}!^/excluded-folder/

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^ index.php [L]