htaccess的图像重定向 [英] .htaccess image redirect

查看:177
本文介绍了htaccess的图像重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个PHP类将水印添加到图像时,当通过URL直接访问的伟大工程。我想每一个形象重定向我的网址,像这样:

I've written a PHP class to add a watermark to an image, it works great when accessed via URL directly. I would like to "redirect" every image to my URL like so:

http://www.mysite.com/img.jpg

http://www.mysite.com/watermark/watermark.php?image=http://www.mysite.com/img.jpg

基本上我想要的是通过在HTML的图像变量指定的src属性。我目前正在挣扎的我的.htaccess 文件,我不能让它的工作,那就是:

Basically what I want is to pass the src attribute specified in the HTML to the image variable. I'm currently struggling with my .htaccess file and I can't get it working, here it is:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([^_].*\.(gif|jpg|png))$ /watermark/watermark.php?image=$1 [L]

期待您的答复,并在此先感谢!

Looking forward to your replies and thanks in advance!

推荐答案

试试这个:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*)\.(jpg|png|jpeg|gif)$ watermark/watermark.php?image=$1.$2 [NC,L]

这篇关于htaccess的图像重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆