.htaccess url重写排除某些目录

时间:2014-10-29 20:19:34

标签: .htaccess url rewrite

我有一个url重写的问题,我必须排除一些目录,因为有一些文件作为CSS,图像和其他。但是我必须

RewriteEngine On

RewriteCond %{REQUEST_URI} !configurazione/ [OR] 
RewriteCond %{REQUEST_URI} !funzioni/ [OR]
RewriteCond %{REQUEST_URI} !img/ [OR]
RewriteCond %{REQUEST_URI} !imgprodotti/ [OR]
RewriteCond %{REQUEST_URI} !imgslider/ [OR]
RewriteCond %{REQUEST_URI} !js/ [OR]
RewriteCond %{REQUEST_URI} !palma/ [OR]
RewriteCond %{REQUEST_URI} !sezioni/ 

RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+).html$ index.php?pag=$1&prodotti=$2&prodotto=$3  [L]
RewriteRule ^([a-z]+)/([a-z]+)/ index.php?pag=$1&prodotti=$2  [L]
RewriteRule ^([a-z]+)/ index.php?pag=$1 [L]

1 个答案:

答案 0 :(得分:0)

RewriteCond仅适用于下一个RewriteRule。请使用THE_REQUEST

尝试使用此代码
RewriteCond %{THE_REQUEST} /(funzioni|img|imgprodotti|js|palma|sezioni|configurazione)/ 
RewriteRule ^ - [L]

RewriteRule ^([a-z]+)/([a-z]+)/([a-z]+).html$ index.php?pag=$1&prodotti=$2&prodotto=$3  [L,QSA]
RewriteRule ^([a-z]+)/([a-z]+)/ index.php?pag=$1&prodotti=$2  [L,QSA]
RewriteRule ^([a-z]+)/ index.php?pag=$1 [L,QSA]