【问题标题】:Problem when i try to convert the htaccess to nginx file, triggers a download当我尝试将 htaccess 转换为 nginx 文件时出现问题,触发下载
【发布时间】:2020-06-03 02:31:58
【问题描述】:

如何将此 .htaccess 转换为 NGINX?

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico|map)(\?|$) /404error.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我试过了:

  location / {

        try_files $uri $uri/ /index.php?$args;
    }

但总是当我点击另一个链接到另一个地址时,它会触发下载一个名为download的文件

这是一个普通网址的例子 http://forum.example.net/index.php?/discover/

应该如何: http://forum.example.net/discover/

我正在使用 ipboard v4.4.10

【问题讨论】:

    标签: .htaccess nginx


    【解决方案1】:

    尝试添加一个 php 位置块

    location ~ \.php$ {
        ...
        include fastcgi_params;
        fastcgi_pass php;
    }
    

    参考:Nginx serves .php files as downloads, instead of executing them

    【讨论】:

      猜你喜欢
      • 2021-01-01
      • 1970-01-01
      • 2011-07-12
      • 2016-05-08
      • 2013-08-11
      • 1970-01-01
      • 2016-01-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多