简体   繁体   中英

.htaccess Rewrite except one subfolder

I have some rewrite rules in my .htaccess and I want to add an exception subfolder so the mod_rewrite stop rewritting when a user links to this subfolder.

My exceptional subfolder is http://simplyservices.gr/aivali When someone reaches this url the mod_rewrite follows the rules I've added and finally user cant see aivali's contents Here is my .htaccess

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/aivali/ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]*)\.html$ /new1/products.php?kategory=$1 [L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /new1/products.php?kategory=$1&subkategory=$2 [L]
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /new1/products.php?kategory=$1&subkategory=$2&id=$3 [L]

I've tried everything that mentioned in same posts but nothing worked. I think its something wrong in my RewriteRules.

Thanks

RewriteConds only mask the following RewriteRule each.

Therefore your !-f , !-d and !-d checks only apply to the first once. Which is probably redundant to begin with, unless there are really dir/dir/*.html files.

Now more interestingly RewriteCond %{REQUEST_URI} !^/aivali/ [NC] also just masks the first RewriteRule. Yet the first RewriteRule only matches basename.html , never something like aivali/sub.html

You should move that RewriteCond-exception in front of the second RewriteRule, because that's the one which would primarily catch it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM