So, I've been trying to figure this out for the past 8 hours, but it seems I'm stuck...
I have the following Nginx config file:
server_tokens off;
upstream php-handler {
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name domain.net;
access_log /var/log/nginx/domain.net-access.log;
error_log /var/log/nginx/domain.net-error.log;
location ~* \.(jpg|jpeg|gif|png|js|css|ico|eot|woff|ttf|svg|cur|htc|xml|html|tgz)$ {
expires 24h;
}
root /var/www/html/domain.net;
index index.php;
location ~ ^/cars/sale(.*) {
add_header X-Robots-Tag "noindex, nofollow" always;
try_files $uri $uri/ /index.php;
}
location ~ ^/(?:\.htaccess|config){
deny all;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass php-handler;
fastcgi_read_timeout 120s;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
}
The issue is that the X-Robots-Tag from the "/cars/sale" location is not added, no matter what I tried. I'm guessing that this is because the request is passed to the final ".php" location where any previously added header is forgotten. Is there any way in which I could add this header only for that specific location without using more_set_headers?