We help IT Professionals succeed at work.

RewriteCond Exclude a folder

tolgaong
tolgaong asked
on
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

Comment
Watch Question

Top Expert 2005

Commented:
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 ...
Top Expert 2005

Commented:
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

Author

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

Top Expert 2005
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