[英]nginx rewrite rules to match apache rewrite for php-login
背景:我在项目中使用了此php应用程序
https://github.com/panique/php-login/
当我开始时,我从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 ($request_uri ~ .*dist.*) {
rewrite ^(.+)$ http://example.com/app/dist/index.php?url=$1; }
我都尝试过
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;
}
nginx try_files是您要寻找的。 您可以看一下配置示例 (在网站上搜索php),以更好地了解nginx + php。
location / {
try_files $uri $uri/ /app/dist/index.php?url=$uri$args;
}
更改rtrim
以trim
application/libs/Bootstrap.php
第74行。
然后,这使其与非常流行且快速增长的Nginx服务器兼容,而不会破坏与Apache的兼容性。
有关更多信息,请参见以下GitHub问题: https : //github.com/panique/php-mvc/issues/55
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.