nginx 重写 Bamboo 发票规则

nginx 重写 Bamboo 发票规则

我刚刚将 Web 服务器从 Apache 迁移到 nginx,但无法使 .htaccess 转换正常工作。我尝试使用的应用程序是 bamboo invoice [http://bambooinvoice.org/],它带有一个默认的.htaccess,如下所示:

RewriteEngine on
RewriteRule ^$ /index.php [L]
RewriteCond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico|update\.php|install\.php)
RewriteRule ^(.*)$ /index.php/$1 [L]

有人能建议如何将这组重写规则转换为 nginx 格式吗?我运气不好。

答案1

尝试这样的操作:

location ~* (index\.php|img|css|js|robots\.txt|favicon\.ico|update\.php|install\.php) {
  try_files $uri =404;
}
location / {
  try_files /index.php$uri;
}

这种匹配似乎有点过于宽容;对路径或文件名中任何地方带有“img”、“js”或“css”的任何内容的请求都会捕获静态内容规则。

答案2

现在有一个名为Apache2Nginx的工具。它可以帮助将配置文件从Apache迁移到Nginx。 https://github.com/nhnc-nginx/apache2nginx/wiki/Welcome-to-Apache2Nginx

相关内容