Is there a .htaccess script I can use to redirect the url of an image to an actual web page?
What can I do to make it so when someone accesses an image via their address bar by typing in: http://www.sitename.com/uploads/192-file-name-here.jpg or other extensions like http://www.sitename.com/uploads/235-file-name-here.png
It will instead redirect the user to the web page: http://www.sitename.com/view/192-file-name-here/
I want to still be able to place the images in image tags across the site and on external sites though.
RewriteCond %{HTTP_REFERER} !^https?:\\www\.sitename\.com
RewriteCond %{REQUEST_URI} (.*)\.jpg$
RewriteRule images/(\d+)\.jpg http://www.sitename.com/view/$1.html [L,R=301]
RewriteCond %{HTTP_REFERER} ^$
Can this be modified/re-written to perform my function?
put this in your
.htaccess
, it will redirect all requests that are sent directly by user.Note: Other sites,as you mentioned can put your images in their pages.
Yes you can always redirect images to a webpage or anything using
.htaccess
. Butimages/(\d+).*\.jpg
may be better.