I want to set noindex some URLs. If any URL contains ?lang= | (start with) /plugin | (start with) /account it should be noindex by adding HTTP header in NGINX configuration.
I tried below code before,
location ~ .*/(?:?lang|plugin|account)/.* {
add_header X-Robots-Tag "noindex, follow" always;
}
Other NGINX location directives that I use for my website: (These default directive for my script are working well.)
#Disable access to sensitive files
location ~* /(app|content|lib)/.*\.(po|php|lock|sql)$ {
deny all;
}
#CORS headers
location ~* /.*\.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js) {
add_header Access-Control-Allow-Origin "*";
}
#Upload path for image content only and set 404 replacement
location ^~ /images/ {
location ~* (jpe?g|png|gif) {
log_not_found off;
error_page 404 /content/images/system/default/404.gif;
}
return 403;
}
#Pretty URLs
location / {
index index.php;
try_files $uri $uri/ /index.php?$query_string;
}
Although no error messages when I reload the Nginx, the noindex directive doesn't appear.