使用正则表达式从URL RewriteRule中排除thumb文件夹

时间:2011-05-11 09:06:51

标签: regex .htaccess mod-rewrite watermark

    RewriteEngine On
 RewriteRule ^(.+)\.jpg$ watermark.php?image=$1\.jpg [L]
 RewriteRule ^(.+)\.gif$ watermark.php?image=$1\.gif [L]
 RewriteRule ^(.+)\.png$ watermark.php?image=$1\.png [L]
 RewriteRule ^(.+)\.bmp$ watermark.php?image=$1\.bmp [L]

我想将缩略图排除在应用水印之外:

http:// ... /gallery/photos/4db83e206ae00/4db83e559209e.jpg 是!

http:// ... /gallery/photos/4db83e206ae00/thumb/4db83e559209e.jpg 不!

1 个答案:

答案 0 :(得分:2)

你可以这样做:

RewriteCond $1 !/thumb/
RewriteRule ^(.+)\.(jpg|gif|png|bmp)$ watermark.php?image=$0 [L]