very specific htaccess redirect - is it possible?

#1
I'm looking to redirect image URL's to page URL's, I've found solutions for Apache on stackoverflow, but they don't seem to work, so I'm trying to post a question here...

what I would like to achieve is to redirect all the image URL's (ending with .jpg, .jpeg and .gif) ie.:
http://mysite.com/wp-content/uploads/image-name.jpg

to URL's like this:
http://mysite.com/image-name/

is it even possible? any help? I'd be super greatful, thanks!
 
#3
I'm also using cloudflare integration and basically when I open a jpeg on my site's URL nothing happen - could this be due to external cloudflare caching? (so that cloudflare just shows the image to the client and htaccess is not even parsed?)
 
#5
tried to test it on a site with no cloudflare caching, and still would love to have some help. the code is:

RewriteEngine On
RewriteRule ^wp-content/uploads/([^.]+)\.(jpg|jpeg|png|gif)$ http://mysite.com/$1 [L,QSA]

and it basically does the job (mysite.com/wp-content/uploads/image-test.jpg redirects to mysite.com/image-test/)

BUT it also breaks all the images inside the htmls so they won't appear there.

do you think it's possible to target only hotlinking and NOT target images within the site?

code was originally posted here as an answer:
http://stackoverflow.com/questions/14093506/htaccess-rewrite-url-only-with-png-jpg-extensions

my PHP version is 5.4.13-dh102 and my LiteSpeed is V5.5
 
Top