htaccess "Header set X-Robots-Tag noindex" works for .html only, doesn't work for .jpg or .pdf

147 Views Asked by At

I have a shared webspace where I use .htaccess with no problems so far.
Today I created a directory with some PDFs and JPGs inside. Not secret, but I don't like to see it in search results. Structure is like this:

http://example.org/foo/bar/

# http://example.org/foo/.htaccess

Header set  X-Robots-Tag noindex

This should set the header for any file in /foo and /foo/bar
Result:

http://example.org/foo/, http://example.org/foo/test1.html/, http://example.org/foo/bar/, http://example.org/foo/bar/test2.html/ return the X-Robots header as expected.

Doesn't work for http://example.org/foo/test.jpg/ or http://example.org/foo/bar/test.pdf/.

Header set X-Robots-Tag works only for HTML, not for JPG and PDF and likely other files.
I also tried things like <files "*.pdf">.

I think this should work, yes? What can I do?

jj

EDIT: Server is a combination of NGINX and Apache

0

There are 0 best solutions below