Happy New year all.
My xmas project was a little website that basically shows a picture you comment and you move on , nothing special.
Images are stored in a folder called "images". I can redirect anyone who accesses that folder to a page of my choice but i CANNOT figure out how to redirect a user to a page if they hit an image from a link directly.
For example if a user shares an image on facebook and another user hits the link they get just the image..no page. Id like them to get to the homepage.
Ive tried RedirectMatch 301 (.*)\.png$ http://www.example.com
But this stops the actual site loading the image also.
Any suggestion would be great.
Thanks
Allen
Edit.
Solved!
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain\.co.uk [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule \.(jpe?g|gif|png)$ [
mydomain.co.uk...] [NC,L]
basically allow myself as a refrer but anyone else requesting extensions get sent elsewhere.