【问题标题】:Nginx configuration difficultyNginx 配置难点
【发布时间】:2014-05-16 21:20:35
【问题描述】:

这是我的 nginx 设置的样子

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

当我转到 url mydomain.com/something.php?arg1=2 时,它会在根目录中查找 something.php,然后返回 file not found message

但我需要的是,如果根目录中没有与当前路由匹配的 .php 文件,则使用当前 url 作为 index.php 的参数,例如 index.php/something.php?arg1=2

如何解决这个问题?

【问题讨论】:

    标签: php url nginx routes


    【解决方案1】:

    试试:

    try_files $uri $uri/ /index.php?q=$uri&$args;
    

    因为您的版本会查找 index.php/something.php,而要使其正常工作,index.php 必须是一个目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-15
      • 2015-05-21
      • 2016-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多