For some reason, this is not working: location ^~ /ajax/ { return 444; include /usr/local/nginx/conf/php-safe.conf; } It only works when accessing folder directly, but not on PHP Files. Any ideas why?