I have product images on website. In 'images' directory they are present as 1.jpg, 2.jpg and so on. 1, 2 are product ids from database and therefore I have put images name as product id (as it would be easier to add/update images) for a product.

For SEO, I have read it is good to have filename something like product-name.jpg (in this case) etc. I want to keep filename as Id based only in images directory but in tag I want to have filename something like src='images/product-name.jpg'. This could be achieved by .htaccess where product-name.jpg would render images/1.jpg.

I want to know in this case for SEO purpose, filename being considered would be product-name.jpg or 1.jpg as actual path in fileserver is images/1.jpg?


1 Answer 1


Image names primarily help image search and not content search so much. I do recommend that image names reflect what the image is.

This does help search engines to know what the image is and how it relates to the content. Image names help support content semantics where the file name matches using semantic topical analysis. Otherwise, where the image file name does not match, it lends no additional semantic topical support. The effect is small, but beneficial.

While I do recommend, if at all possible, using a real file name that semantically reflects what the image is, using .htaccess to rewrite (not redirect) the request should be transparent. It is a purely internal process and should satisfy the request for the file name within the HTML just fine. Would I do this? No. I would rework the system so that the database can provide a more meaningful file name when rendering the HTML. I do get how it is far simpler to take the product ID and simply look for an image of that name. I do get it - honest I do. However, for systems that I have written, taking these short-cuts often cost you something. It can be inflexibility, more work, etc. Either way, you should be fine.

  • Yes, image filename related to product would be good for SEO. I wanted to know for .htaccess approach search engine would be considering product-name.jpg or 1.jpg (as actual path in fileserver is images/1.jpg)?
    – kb0000
    Commented Mar 8, 2017 at 5:27
  • @kb0000 If the file name in the HTML is the product name and you rewrite any request for the file name to the actual file 1.jpg, that should work. A rewrite is transparent. I am assuming Apache of course. For IIS and others, that would remain to be seen, however, I assume it is the same. Be sure not to do a redirect R or R=301 but a rewrite without the R.
    – closetnoc
    Commented Mar 8, 2017 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.