Forum Moderators: phranque
RewriteRule ^(.*)/$ test1.php?url=$1 [L]
RewriteRule ^(.*)/(.*)/$ test2.php?url=$1&id=$2 [L]
....
But I want to apply another rewrite rule to \folder1\.htaccess, who can I ignore this folder in the root .htaccess file? Perhaps I need to add some lines like RewriteCond?
RewriteRule ^(.*)/$ test1.php?url=$1 [L]
RewriteRule ^(.*)/(.*)/$ test2.php?url=$1&id=$2 [L]
In addition, using ".*" can be very inefficient when two or more such subpatterns are present, as mod_rewrite will have to evaluate the string from both ends to figure out how to divide the string between the two subpatterns.
I'd suggest:
RewriteRule ^([^/]+)/$ test1.php?url=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/$ test2.php?url=$1&id=$2 [L]
The simple solution to /folder1/.htaccess is to put the rule for /folder1/.htaccess before the rules above, and use a positive-logic RewriteCond:
RewriteCond %{REQUEST_URI} ^/folder1/\.htaccess
RewriteRule <whatever your rule is> [L]
<code for test1 and test2 follows>
RewriteCond %{REQUEST_URI} !^/folder1/\.htaccess
RewriteRule ^([^/]+)/$ test1.php?url=$1 [L]
RewriteCond %{REQUEST_URI} !^/folder1/\.htaccess
RewriteRule ^([^/]+)/([^/]+)/$ test2.php?url=$1&id=$2 [L]
RewriteRule ^folder1/\.htaccess - [S=2]
RewriteRule ^([^/]+)/$ test1.php?url=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/$ test2.php?url=$1&id=$2 [L]
Jim