【问题标题】:Nginx rewriting not enabled in server服务器中未启用 Nginx 重写
【发布时间】:2015-09-17 08:57:17
【问题描述】:

我必须更改 nginx 的配置,以便 public_html 文件夹中的 index.php 处理除文件和文件夹之外的所有请求。

我知道如何在 htaccess 中做到这一点

喜欢这个

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /index.php?path=$1 [NC,L,QSA]

当我搜索时,我发现 nginx 配置文件中的这段代码会做同样的事情。

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

我确实在配置文件中进行了设置。

但是,主页可以正常工作,但是 www.example.com/login 等其他路由不起作用。

但是,example.com/index.php/login 显示的是 www.example.com/login 的内容

在这种情况下会出现什么问题?

我对 nginx 很陌生,对它的了解很少。

有人可以帮忙吗?

【问题讨论】:

    标签: php .htaccess nginx


    【解决方案1】:

    你可以这样改写:

    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?path=$1 last;
        break;
    }
    

    【讨论】:

      猜你喜欢
      • 2020-01-30
      • 2023-04-08
      • 2016-11-14
      • 2016-03-31
      • 2011-09-16
      • 2020-05-03
      • 1970-01-01
      • 1970-01-01
      • 2016-11-03
      相关资源
      最近更新 更多