The Nginx config I have throws 404 for .php like:
## Any other attempt to access PHP files returns a 404. location ~* ^.+\.php$ { return 404; } However I have some index.php file in subfolder that I want to run. The current config is like:
location = /sitename/subpage/index.php { fastcgi_pass phpcgi; #where phpcgi is defined to serve the php files } location = /sitename/subpage2/index.php { fastcgi_pass phpcgi; } location = /sitename/subpage3/index.php { fastcgi_pass phpcgi; } it works perfectly, but the issue is duplicate locations and if there are lots of subpages then the config becomes huge.
I tried the wildcard like * and some regex, which says the nginx test passed but doesn't load the page i.e. 404. What I tried are:
location = /sitename/*/index.php { fastcgi_pass phpcgi; } location ~* ^/sitename/[a-z]/index.php$ { fastcgi_pass phpcgi; } Is there any way I can have some pathname in the location as regex or wildcard?