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?
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;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.