Hey, this might be a really obvious fix, but I cannot seem to figure it out.
I have a vhost setup with a rewrite using try_files to remove the .html extension off files, I think it looks cleaner. So for example, instead of people visiting example.com/about.html, they actually use example.com/about. It works with the htm files and I wanted to do the same thing with a php page that houses a simple contact us form, but with the current setup it looks like the file is not being passed to php-fpm. So when someone visits the page, they have access to the raw php code.
Here is what my vhost looks like:
server {
server_name example.com www.example.com;
root /home/www/example.com;
index home.html index.html index.php;
# set expiration of assets to MAX for caching
location ~* \.(ico|css|js|gif|jpeg|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
break;
}
location ~* ^/([a-zA-Z0-9\-]+)$ {
try_files /$1.php /$1.html /404.html;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\. {
deny all;
}
}
If anyone can point out what I am doing wrong it would be much appreciated.