htaccess的重写条件/查找文件名模式重写、文件名、条件、模式

由网友(低着头沉默)分享简介:我要特定的图像文件夹中进行水印。我得到了下面的htaccess-块这是工作的好:RewriteEngine叙述上的RewriteCond%{REQUEST_URI} ^ /媒体/图像/缩略图/(*)([GIF | JPE G |?PNG | BMP])$重写规则^(。*)/watermark/watermark.p...

我要特定的图像文件夹中进行水印。我得到了下面的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]
 
如何在EXCEL中按条件查找

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]

阅读全文

相关推荐

最新文章