timthumb.php friendly URL with .htaccess

timthumb.php is a resizing/cropping php script, used in thousands of websites, I’m using it in my wordpress blog, and I’m facing a issue.

I use a plugin that changes the wordpress default’s paths for security reasons, like:

Read More

Example

Before
mysite.com/wp-content/uploads/2013/03/example.jpg
After
mysite.com/images/example.jpg

timthumb simply won’t recognize the new path, it seems to retrieve a 404 error, it can’t find the image

My issue:

enter image description here

If you try to access example.jpg directly it works normally, but with timthumb it doesn’t
mysite.com/images/example.jpg
You can see the image, even if the file is actually in
mysite.com/wp-content/uploads/2013/03/example.jpg
but timthumb won’t recognize it and outputs the above error

Current .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteRule ^images/(.*) /wp-content/uploads/$1 [QSA,L]
RewriteRule ^lib/(.*) /wp-content/themes/mytheme/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/wp-content/themes/mytheme/$ lib/ [R,L]
RewriteRule ^/wp-content/uploads/$ images/ [R,L]
RewriteRule ^lib/$ /wp-content/themes/mytheme/ [L,NC]
RewriteRule ^images/$ /wp-content/uploads/ [L,NC]
</IfModule>

Related posts

Leave a Reply

1 comment

  1. timthumb looks for a path, have you opened and looked to edit the php?

    I had to customize timthumb after changing directories as well… I’ll look for my code.

    timthumb pulls the actual path as it is excecuted server side.

    .htaccess is used to pull images from outside thru a web browser.

    your files are actually located /public_html/wp-content/uploads/yr/mo/xxxx.xxx

    so the script is trying to decode a location that does not exist.

    You might be able to ln (soft link the images folder to the uploads folder server side)

    this will allow the script to run properly without modification.