问题
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
回答1:
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&w=250&h=250&" />
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&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&w=$1
Source
来源:https://stackoverflow.com/questions/16720646/timthumb-htaccess-rewrite