Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nginx重写规则与apache rewrite for php登录匹配_Php_Apache_.htaccess_Nginx - Fatal编程技术网

nginx重写规则与apache rewrite for php登录匹配

nginx重写规则与apache rewrite for php登录匹配,php,apache,.htaccess,nginx,Php,Apache,.htaccess,Nginx,背景: 我在我的项目中使用了这个php应用程序 当我开始的时候,我开始使用apache并完成了我的整个项目。 但当我不得不将其推送到生产服务器时,它们只支持nginx 我试图转换重写规则,但仍然不起作用 谢谢你的帮助 Apache.htaccess RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.

背景: 我在我的项目中使用了这个php应用程序

当我开始的时候,我开始使用apache并完成了我的整个项目。 但当我不得不将其推送到生产服务器时,它们只支持nginx

我试图转换重写规则,但仍然不起作用 谢谢你的帮助 Apache.htaccess

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
我尝试使用nginx(考虑dist是我的应用程序所在的文件夹)

我两者都试过了

if (!-e $request_filename){
      rewrite ^/dist/(.+)$ index.php?url=$1 last;
      }

我还联系了github的所有者,他是支持nginx的大亨。

我认为这应该行得通,但我忽略了
-l
标志,因为我真的不知道nginx对应的语法是什么,我也不认为这很重要

location /whatever {
  try_files $uri $uri/ @fallback;
}
location @fallback{
  rewrite ^ /index.php?url=$1&$query_string;
}

application/libs/Bootstrap.php的第74行中的
rtrim
更改为
trim

这样,它就可以与非常流行和快速增长的nginx服务器兼容,而不会破坏与Apache的兼容性

有关更多信息,请参阅此GitHub问题:

是您正在寻找的。您可以查看(在站点上搜索php)以更好地了解nginx+php

location / {
    try_files $uri $uri/ /app/dist/index.php?url=$uri$args;
}

有很多将apache转换为nginx的示例。我想,在这种情况下,您应该使用
try\u文件
这并不能真正回答问题。如果您有不同的问题,可以单击以提问。你也可以提醒大家注意这个问题。@John,这是同一个问题。
location / {
    try_files $uri $uri/ /app/dist/index.php?url=$uri$args;
}