Stripping down the nginx.conf file: server{ location / { root /usr/share/nginx/html/mydomain/public_html; if ($badagent) { return 403; } } location = /feeds { try_files $uri $uri.xml $uri/ ; } } The "=" should force an exact match, but the badagent map is checked.