I was shown this rewrite for getting images to redirect to a particular web page. And it allows for the usage of images on my site and others.
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{REQUEST_URI} ^/uploads/(\d+)-(.+)\.(png|gif|jpe?g|bmp)$ [NC]
RewriteRule (.*) http://www.sitename.com/view/%1-%2/
This works great if I try to directly access an image from the address bar and I’m currently viewing my site. The problem I am noticing is if a user writes out a link on another site:
<a href="http://www.sitename.com/uploads/123-Charizard.png">Click</a>
It will take them to that image, not to the page.
What modifications should I be making to the rewrite so that it will redirect the user to the /view/ page.
EDIT: Another thing I have noticed is when posting an image to Facebook, using the above rewrite, it will not display the thumbnail as it once did. I am assuming this is something that cannot be worked around?
For prevent caching: