I need to add a noindex tag to multiple specific uploaded files, but they all belong to different year and month upload folders like this for example:
/var/www/public/app/uploads/2021/06/file-1.pdf/var/www/public/app/uploads/2018/11/file-2.pdf/var/www/public/app/uploads/2011/07/file-3.pdf
I did this initially, but did not work:
location ~ "^(.*)/app/uploads/(.*)$" {
location ~ ^/(file-1.pdf|file-2.pdf|file-3.pdf)$ {
add_header X-Robots-Tag "noindex";
}
}
I don't have access yet to test, but this is what I'm planning to do instead:
location ~ "/var/www/public/app/uploads/(.*)$" {
location ~ ^/(file-1.pdf|file-2.pdf|file-3.pdf)$ {
add_header X-Robots-Tag "noindex";
}
}
I wonder if there is a better approach, or if this will even work. Right now there are 27 specific files I have to do this to so I'm not sure if the file-1.pdf|file-2.pdf|file-3.pdf is my best option.
Any help is appreciated, thanks.