htaccess的重写条件/查找文件名模式 [英] htaccess rewrite condition / find pattern in file names
问题描述
我要特定的图像文件夹中进行水印。我得到了下面的htaccess-块这是工作的好:
RewriteEngine叙述上
的RewriteCond%{REQUEST_URI} ^ /媒体/图像/缩略图/(*)([GIF | JPE G |?PNG | BMP])$
重写规则^(。*)/watermark/watermark.php?src=$1 [L]
不过,我只想水印更大的缩略图。有在我们的系统的命名惯例这增加图像的尺寸以文件名。一个典型的名称是:
img1_285x255.png
因此,如何将我不得不改变的.htaccess才能访问文件,其名称为285x255.png为例结束?
结束
那么,如何将我不得不改变的.htaccess才能访问文件,其名称为285x255.png的例子吗?
您可以做这样的事情:
重写规则^(。+?285x255 \巴纽)$ /watermark/watermark.php?src=$1 [L,NC,QSA]
I want certain images in a folder to be watermarked. I got the following htaccess-chunk which is working well:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/media/image/thumbnail/(.*)([gif|jpe?g|png|bmp])$
RewriteRule ^(.*) /watermark/watermark.php?src=$1 [L]
However I only want to watermark the bigger thumbnails. There is a naming convention in our system which adds the dimensions of an image to the file name. A typical name would be:
img1_285x255.png
So how would I have to change the .htaccess in order to access files whose names end with "285x255.png" for example?
So how would I have to change the .htaccess in order to access files whose names end with "285x255.png" for example?
You can do something like this:
RewriteRule ^(.+?285x255\.png)$ /watermark/watermark.php?src=$1 [L,NC,QSA]
这篇关于htaccess的重写条件/查找文件名模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!