WordPress.org

Ready to get started?Download WordPress

Forums

.htaccess & timthumb i need help (6 posts)

  1. ShokAIM
    Member
    Posted 10 months ago #

    Ok this is what I'm trying to do : use timthumb.php with external images and remove the query string "?" after goggling a little i've found a way using .htaccess, here is my code:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^cdn-thumb/(.*)$ thumb/timthumb.php?$1 [L]
    </IfModule>

    basically this code replaces the part thumb/timthumb.php?src= with cdn-thumb/src= and it works fine if the image is hosted on my website and I point to it using the relative path ex : wp-content/uploads/123.jpg but when i try using it with a image hosted elsewhere (other domain) it breaks giving 404 error because it removes a slash from http://

    ex:
    http://my-domain.com/cdn-thumb/src=http://domain.com/123.jpg
    i get only
    http://my-domain.com/cdn-thumb/src=http:/domain.com/123.jpg

    so any clue how to fix this ? or alternative solutions ?

  2. leejosepho
    Member
    Posted 10 months ago #

    I know nothing about this myself, but you might take a look at how Bulletproof Security deals specifically with Tim Thumb...and BPS has a Custom Code editor where you can add anything you wish and let BPS make it all work together.
    http://wordpress.org/plugins/search.php?q=BulletProof+Security

  3. ShokAIM
    Member
    Posted 10 months ago #

    nope, doesn't help at all

  4. Can you post a more specific before and after, meaning complete URLs with query string?

  5. ShokAIM
    Member
    Posted 10 months ago #

    i have the following url:
    http://my-domain.com/thumb/timthumb.php?src=http://other-domain.com/123.jpg

    and with .htaccess I try to achieve this:
    http://my-domain.com/cdn-thumb/src=http://other-domain.com/123.jpg
    and doesn't work , i only get
    http://my-domain.com/cdn-thumb/src=http:/other-domain.com/123.jpg
    it strips one slash / from the external image url how can i make the .htaccess to leave that slash... ? or any other option to achieve a clean url without "?"

  6. It's the query string, that usually makes it all difficult...

    If you can get the cdn-thumb/src to work with a query string like then it may work. In this example I'm using ?imagepath

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{QUERY_STRING} src(.*)$
    RewriteCond %{REQUEST_URI} !cdn-thumb
    RewriteRule (.*) http://my-domain.com/cdn-thumb/src?imagepath%1 [R=301,L]
    </IfModule>

    There should be a RewriteCond for ^thumb/timthumb.php too but I had trouble making that work.

Reply

You must log in to post.

About this Topic