1

Do you know if there's a way to alter via htaccess the timthumb urls ? My question is if i can change for example urls like this

thumb.php?src=http://mysite.com/images/image.jpg&h=200&w=350&zc=1&q=80

to

http://mysite.com/images/image.jpg

3 Answers 3

1

Cadeyrn's code work probably for 1 specific size ( 200&w=350& etc) , the major problem with timthumb and the reason people use it, is that it allows for many dynamic sizes thus making .htaccess rewrite rules much more difficult, especially if you using friendly WordPress permalink structure.

There is a guide here on how to do it, it might need tweaking and honestly timthumb should be avoided. http://revisedagain.com/?p=18

1
  • Good link, and you're actually right about the problems. Apr 3, 2011 at 20:55
0

You need to edit the .htaccess file, and add some rewrite rules. This only works with apache2, for other web servers, you need other solution.

Before the main part of the wordpress rewrite rules, but after RewriteEngine On:

# check if the file exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/images/
RewriteRule ^(.*)$ thumb.php?src=http://%{HTTP_HOST}/$1&h=200&w=350&zc=1&q=80 [L]

Please note, I cannot test this right now, and I'm really not sure, it'll work, but you need something like this.

0

you may try this solution:

http://revisedagain.com/2011/custom-rewrite-rules-with-wordpress-timthumb/

from URL above:

This rule tells the server that

http://www.domain.com/resize/160×130/r/wp-content/uploads/2011/03/pic.jpg

should be interpreted as

http://www.domain.com/resize/timthumb.php?src=/wp-content/uploads/2011/03/pic.jpg&h=130&w=160&c=1
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.