error_page 404 error/404.html; location = error/404.html { internal; } location = robots.txt { allow all; log_not_found off; access_log off; } location = explore/ { index index.html } location ~* explore/(.*)/ { if ($request_uri ~ ^/(.*)\.html) { return 302 explore/$1/; } try_files $uri $uri.html $uri/ =404; } }