【问题标题】:Nginx rewrite equivalent of AcceptPathInfo option from ApacheNginx 重写相当于 Apache 的 AcceptPathInfo 选项
【发布时间】:2015-06-11 18:29:16
【问题描述】:

我开始使用 nginx。在我使用 apache 之前。 并且默认它在 apache 中运行良好(AcceptPathInfo 选项):

SEO 友好的网址: http://testsite.com/anyfile.php/get_param1/get_value1/get_param2/get_value_2 ...等

结果,从 apache 文件转换后看起来: http://testsite.com/anyfile.php?get_param1=get_value1&get_param2=get_value_2 ...等

但是,怎么用nginx呢?它适用于许多和任何文件:anyfile.php、anyfile1.php、anyfile2.php 等......很多文件都使用它。

有可能吗?因为我看到了很多答案,但没有看到任何文件。

非常感谢。

【问题讨论】:

  • 感谢您的回答,但它不适用于任何文件和任何数量的获取参数。例如我的决定。但它只适用于任何文件,而不适用于任何数量的 get 参数:rewrite ^/(.*\.php)/(.*)/(.*)$ /$1?$2=$3 我怎样才能添加很多获取参数? Apache 的 Nginx 等效选项:AcceptPathInfo

标签: mod-rewrite nginx


【解决方案1】:
location ~ [^/]\.php(/|$) {
    # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
    fastcgi_split_path_info  ^(.+\.php)(/.+)$;
    fastcgi_index            index.php;
    fastcgi_pass             127.0.0.1:9000 (or your php-fpm socket);
    include                  fastcgi_params;
    fastcgi_param   PATH_INFO       $fastcgi_path_info;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;

}

https://docs.moodle.org/29/en/Nginx#Slasharguments

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-18
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-13
    • 2017-01-18
    • 1970-01-01
    相关资源
    最近更新 更多