.htaccess RewriteRules到nginx.conf

时间:2014-09-05 10:33:20

标签: .htaccess nginx url-routing

我想转换此.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错误的网关错误。

1 个答案:

答案 0 :(得分:1)

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

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

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