【问题标题】:.htaccess RewriteRules to nginx.conf.htaccess 重写规则到 nginx.conf
【发布时间】:2014-10-30 06:56:56
【问题描述】:

我想转换这个 .htaccess 文件:

Options -MultiViews

RewriteEngine On

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

RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

进入 nginx.conf 文件。到目前为止,我的 nginx.conf 文件如下所示:

server {
  listen 80;
  server_name _;
  root /var/www/app;
  index index.php;

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

  location ~ \.php$ {
    fastcgi_pass 127.0.0.1:8080;
    fastcgi_index index.php;
    include fastcgi_params;
  }
}

我收到 502 bad gateway 错误。

【问题讨论】:

    标签: .htaccess nginx url-routing


    【解决方案1】:

    更正您的位置以与您的 apache 重写兼容:

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

    错误 502 表示 fpm-php (fastcgi) 后端已关闭,但这不是 nginx 问题:)

    【讨论】:

    • 还是不行!不过还是非常感谢您的帮助!
    • location {} 代码无法修复 502 问题,您必须启动 php-fpm 服务,但我们在这里进入离题)
    • 我修复了 502 问题,感谢您的支持。但我的 MVC 仍然无法正常工作。它无法识别链接(索引除外)。
    猜你喜欢
    • 1970-01-01
    • 2014-01-19
    • 2020-01-10
    • 1970-01-01
    • 2011-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多