为什么nginx将phtml文件加载为html文件

时间:2017-12-14 10:14:21

标签: php nginx magento2

我的网站在apache服务器上运行完美。现在我想在 nginx 服务器上实现我的问题就像我的magento的 phtml 文件一样执行 html < /strong>。我尝试在nginx配置文件中添加“*。phtml”扩展名,但没有成功。

这是我的配置文件

cat /etc/nginx/sites-enabled/mydomain.com 


server {
listen 80 default_server;

root /usr/share/nginx/mydomain.com/;
index index.php index.phtml index.html index.htm;

server_name domain.com;
location / {
    try_files $uri $uri/ /index.php;
}

location ~ \.(php|phtml)$ {
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    include snippets/fastcgi-php.conf;
}
}

请建议我如何在nginx中将“ .html”文件解析为“ .phtml”?

1 个答案:

答案 0 :(得分:2)

试试这个:

location ~ \.(php|phtml)$ {
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    include snippets/fastcgi-php.conf;
}