I have an app in node.js and I want to make a route that redirects all hotlinks to images to the article/URL the image was used on.
But since all the images are stored in
/public/img directory and article URLs are generated programmatically, how do I tie down each image to its article? ..in a way that would allow me to redirects all hotlinks to the images to the article/URL the image was used on?
My article is
and it uses the image
because all images are stored in
Then if someone hotlinks to the image
http://www.site.com/img/that-image.jpg, how do I redirect to the article it was used in
http://www.site.com/blog/archives/2013/article-slug/? (I can check whether it was hotlinked probably by checking the
But how do I store the relevant information about which image is used in which article, and how do I use that information to do the redirect?