Reputation: 457
I'm executing PHP code inside some my HTML files, but since I only want to do this on certain files, I want to create .htaccess
rules for specific files only.
My current config works fine but it all my html files, even static ones interpreted through PHP engine;
# handle .php
location ~ \.(php|html|htm)$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
include nginxconfig.io/php_fastcgi.conf;
}
What I tried to far is on .htaccess
file but looks like it only works with Apache;
<Files mypage.html>
AddType application/x-httpd-php .html
</Files>
Should I create location
for each html file I should want to work with PHP?
Upvotes: 0
Views: 962
Reputation: 9845
Use exact matching:
# add another location:
location = /mypage.html {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
include nginxconfig.io/php_fastcgi.conf;
}
Upvotes: 1