RewriteCond Exclude a folder

I need to exclude rewriterules for some folders. In code below it calls the right parameters. If i call another folder like admin or images than apache returns error  "MaxRedirects option has been removed in favor of the global LimitInternalRecursion directive and will be ignored".

RewriteRule ^([a-z]+)-([a-z]+)/index.html$ index.php?lang=$1&country=$2

Open in new window

Who is Participating?
ravenplConnect With a Mentor Commented:
if matched in .htaccess, You need to remove the leading slash from match, eg.

RewriteCond %{REQUEST_URI} !^admin/

Since You match negative, don't use [OR]. NOT A OR NOT B always fires, right?

each rewriteRule need separate set of rewriteConds
Not clear what You want (at least to me), but do You want the following?

#assumin .htaccess usage, otherwise should look like !^/admin/
RewriteCond %{REQUEST_URI} !^admin/
RewriteCond %{REQUEST_URI} !^images/
RewriteRule ...
Or maybe

#only if matched pattern is non-existent directory
RewriteCond $1-$2 !-d
RewriteRule ^([a-z]+)-([a-z]+)/index.html$ index.php?lang=$1&country=$2
tolgaongAuthor Commented:
Thanks ravenpl but it does not work in my local test server...

It gives me the same error... I wrote the .htaccess file below.  I want to exclude the folders "admin, images, scripts and styles"

Do you have any idea for the situation?

Thanks in advance

Options +FollowSymlinks
RewriteEngine On 
RewriteOptions MaxRedirects=10
RewriteCond %{REQUEST_URI} !^/admin/ [OR]
RewriteCond %{REQUEST_URI} !^/images/ [OR]
RewriteCond %{REQUEST_URI} !^/scripts/ [OR]
RewriteCond %{REQUEST_URI} !^/styles/
RewriteRule ^(catchpa).(jpg|gif|png)$ images/scripts/catchpa.php?show=$1&type=$2 
RewriteRule ^([a-z]{2})-([a-z]{2,4})/index.htm[l]?$ index.php?pagelang=$1&pagecountry=$2 
RewriteRule ^([a-z]{2})/([a-z_]+).htm[l]?$ index.php?pagelang=$1&show=$2 
RewriteRule ^([a-z]{2})/([a-z_]+).htm[l]?~(.+)$ index.php?pagelang=$1&show=$2&$3 
RewriteRule ^([a-z]{2})-([a-z]{2,4})/([a-z_]+).htm[l]?$ index.php?pagelang=$1&pagecountry=$2&show=$3 
RewriteRule ^([a-z]{2})-([a-z]{2,4})/([a-z_]+).htm[l]?~(.+)$ index.php?pagelang=$1&pagecountry=$2&show=$3&$4

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.