Timthumb htaccess的重写重写、Timthumb、htaccess

2023-09-02 20:40:28 作者:12.君浅吟

由于如一日,我timthumb停止工作

但没弄清楚,它有可能做的ModSecurity的。

所以下面的,它的工作,直到一小时前。

http://www.HOST.com/wp-content/themes/THEME/scripts/timthumb.php?src=http://www.HOST.com/wp-content/uploads/2013/05/image.jpg&w=70&h=50&zc=1&q=100

现在只能用

http://www.HOST.com/wp-content/themes/THEME/scripts/timthumb.php?src=/wp-content/uploads/2013/05/image.jpg&w=70&h=50&zc=1&q=100

试着把这在我的htaccess的,但没有改变

 #WPhtc:开始自定义htaccess的
的RewriteCond%{REQUEST_URI}!^ /(timthumb)[NC]
?重写规则^脚本/ timthumb.php SRC = / X(*)/ R /(.*)脚本/ timthumb.php SRC = HTTP(*)://www.HOST.com/$3& H = $ 2及W = $ 1和C = 1
#WPhtc:结束自定义的htaccess
 

解决方案

使用TimThumb为您的图像,会导致一些......乱看(又免得面对它,高不可攀)code。观察..

 < IMG ALT =露营SRC =/ timthumb.php SRC = /图片/二月/ image_001.jpg和放大器;放大器; W = 250&放大器;放大器; H = 250安培;放大器; />
 
timthumb.php黑图,TimThumb,一个很赞的php图片剪裁插件

为什么不把凌乱了出来,并使用一些时髦的.htaccess重定向?

 < IMG ALT =露营SRC =/图片/二月/ 250 / image_001.jpg/>
 

那岂不是看起来更好?您的精彩露营图像现在设置为250像素的宽度与高度保持在正确的比例。

TimThumb htaccess的重写 这是非常容易和简单,以实现这一目标!更新你的.htaccess文件,像这样。

 #用另一只的RewriteCond规则
的RewriteCond%{REQUEST_URI}!^ /(图像)[NC]
重写规则^(+)/ $ / $ 1 [R,L]

# 宽度
重写规则^图像/([A-ZA-Z0-9  - ] +)/([0-9] +)/([A-Z0-9] +)$ /tt.php?src=/images/ $ 1 / $ 3放大器;放大器; W = $ 2
 

如果你没有任何形式的文件夹系统和所有的图像都只是扔进图像文件夹,你可以使用以下

 重写规则^图像/([0-9] +)/([A-Z0-9] +)?$ /tt.php?src=/images/$2& ;放大器; W = $ 1
 

来源

Since like a day, my timthumb stopped working

however did figure out that it has probably to do with the modsecurity.

So the following, which worked untill a day ago.

http://www.HOST.com/wp-content/themes/THEME/scripts/timthumb.php?src=http://www.HOST.com/wp-content/uploads/2013/05/image.jpg&w=70&h=50&zc=1&q=100

Now only works using

http://www.HOST.com/wp-content/themes/THEME/scripts/timthumb.php?src=/wp-content/uploads/2013/05/image.jpg&w=70&h=50&zc=1&q=100

Tried putting this in my htaccess, but no change

# WPhtc: Begin Custom htaccess
RewriteCond %{REQUEST_URI} !^/(timthumb) [NC]
RewriteRule ^scripts/timthumb.php?src=/(.*)x(.*)/r/(.*) scripts/timthumb.php?src=http://www.HOST.com/$3&h=$2&w=$1&c=1
# WPhtc: End Custom htaccess

解决方案

Using TimThumb for your images, can lead to some.. messy looking (and lest face it, unattainable) code. Observe..

<img alt="Camping" src="/timthumb.php?src=/images/feb/image_001.jpg&amp;w=250&amp;h=250&amp;" />

Why not take the messy out of it and use some funky .htaccess redirects?

<img alt="Camping" src="/images/feb/250/image_001.jpg" />

Doesn’t that look much better? Your wonderful camping image is now set to 250 pixels in width with the height being maintained at the correct ratio.

TimThumb htaccess rewrite It is very easy and simple to achieve this! Update your .htaccess file, Like so.

# With your other RewriteCond rules
RewriteCond %{REQUEST_URI} !^/(images) [NC]
RewriteRule ^(.+)/$ /$1 [R,L]

# Width
RewriteRule ^images/([a-zA-Z0-9-]+)/([0-9]+)/([a-z0-9.]+)?$ /tt.php?src=/images/$1/$3&amp;w=$2

If you don’t have any sort of folder system and all your images are just thrown into the images folder, you can just use the following

RewriteRule ^images/([0-9]+)/([a-z0-9.]+)?$ /tt.php?src=/images/$2&amp;w=$1

Source

 
精彩推荐