基本url重写nginx错误500或下载
我仍然无法找到一种方法来正确配置我的nginx服务器,以便我的网站的url被重写为我想要的方式。这看起来很容易(在我的apache服务器上也是如此),但我不知道问题出在哪里 我想做的很简单: 让浏览器显示:“/portfolio/project/projectname” 在传递到服务器“/portfolio/project.php?project=projectname”时 这是我的nginx custom.conf文件:基本url重写nginx错误500或下载,url,nginx,rewrite,php,Url,Nginx,Rewrite,Php,我仍然无法找到一种方法来正确配置我的nginx服务器,以便我的网站的url被重写为我想要的方式。这看起来很容易(在我的apache服务器上也是如此),但我不知道问题出在哪里 我想做的很简单: 让浏览器显示:“/portfolio/project/projectname” 在传递到服务器“/portfolio/project.php?project=projectname”时 这是我的nginx custom.conf文件: server { listen 80; server_name
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文件
谢谢你的帮助 因此,实际上我的nginx conf是正确的,我激活了错误日志,如下所示,并发现这是一个php错误
error_log /var/log/remitod.error.log;
下面是代码
rewrite^/portfolio/project/([^/]+)(/?)$/portfolio/project.php?project=$1代码>谢谢你的回答,但我仍然得到一个500错误…如果配置它应该在位置/{rewrite^/portfolio/project/([^/]+)(/?)$/portfolio/project.php?project=$1;}
抱歉,但仍然是错误500…请尝试删除这些行,最后重试rewrite^/$/portfolio;最后重写^/contact/contact.php
或将其移动到位置/{}