We can add custom extension for php files in Nginx. We can do this by following below steps:
Open the /etc/nginx/nginx.conf file and locate the following lines:
location ~ .*\.php$ {
root /var/www/html/www.domain.com;
if (!-f $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1;
break;
}
include fastcgi_params;
#root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_intercept_errors off;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/www.domain.com$fastcgi_script$
}
We can edit the first line shown above and change it as follows to add '.ext' as the custom file extension.
location ~ .*\.php|.*\.ext$ {
Next step is to restart the Nginx server /etc/init.d/nginx restart
Now we can create a .htaccess file. Add the following line to the file, and place it under the document root.
Addhandler application/x-httpd-php .html .php .ext