基本网址重写nginx错误500或下载

时间:2014-07-20 15:41:34

标签: url nginx rewrite php

我仍然无法找到正确配置我的nginx服务器的方法,以便我网站的网址按照我想要的方式重新编辑。它似乎很容易(而且,在我的apache服务器上),但我无法弄清问题在哪里。

我想做的很简单: 浏览器显示:“/ portfolio / project / projectname” 传递给服务器“/portfolio/project.php?project=projectname”

这是我的nginx custom.conf文件:

server {
  listen 80;

  server_name remitod.com www.remitod.com;

  root /var/www/html/remitod/;

  error_page 404 errors/404.html;

  index index.php index.html index.htm;


  rewrite ^/$ /portfolio last;
  rewrite ^/contact /contact.php last;

  #
  # Here is the line in question
  #
  rewrite ^/portfolio/project/(.+)$ /portfolio/project.php?project=$1 last;


  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log off;
    expires max;
  }

  location ~ \.php(.*)$ {
    include fastcgi_params;
    fastcgi_intercept_errors on;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }

  location ~ /\.ht {
    deny  all;
  }
}

现在,这给了我一个500错误; 我尝试通过“break”更改重写规则末尾的“last”,它的作用是让我下载php文件!

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

所以实际上我的nginx conf是对的,我按如下方式激活了错误日志,发现这是一个php错误......

error_log /var/log/remitod.error.log;