【问题标题】:why nginx load phtml files as html files为什么nginx将phtml文件加载为html文件
【发布时间】:2018-05-28 09:25:18
【问题描述】:

我的网站在 apache 服务器上完美运行。现在我正在尝试在 nginx 服务器上实现,我遇到了问题,比如我的 magento 的 phtml 文件执行为 html。我尝试在 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”?

【问题讨论】:

    标签: php nginx magento2


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 2015-09-05
      • 2019-07-11
      • 1970-01-01
      • 1970-01-01
      • 2019-03-14
      • 2020-03-23
      • 2020-08-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多