rewrite 帮看一下 注册404
By
nohup
at 2018-05-09 • 1人收藏 • 6249人看过
location /
{
include rewrite.conf
root "C:/Users/Administrator/Desktop/wnmps/webroot";
index index.php index.html index.htm;
}
22 个回复 | 最后更新于 2018-05-09
回复#3 @lincanbin :
额,奇怪了,那为什么我还是404,我还去github上参考了那这个文件
https://github.com/lincanbin/Carbon-Forum/blob/master/docker_resources/nginx_default.conf
除了这一句
fastcgi_split_path_info ^(.+\.php)(/.+)$;
以外并没有什么差别,我的php cfi.fix_pathinfo=0的
以下是我的nginx站点配置
server {
listen 80;
server_name localhost;
#charset koi8-r;
access_log D:/nginx/html/bbs/access.log;
error_log D:/nginx/html/bbs/error.log;
root D:/nginx/html/bbs;
index index.php;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 7d;
access_log off;
}
location ~ .*\.(js|css)$ {
expires 12h;
access_log off;
}
# rewrite
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /.git {
deny all;
return 403;
}
location /controller {
deny all;
return 403;
}
location /docker_resources {
deny all;
return 403;
}
location /library {
deny all;
return 403;
}
location /service {
deny all;
return 403;
}
location /view {
deny all;
return 403;
}
error_page 404 /404.php;
error_page 500 502 503 504 /500.html;
location = /500.html {
root /usr/local/nginx/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/phpfpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}回复#4 @test2 :
root /www/web/carbon/public_html; include /www/web/carbon/public_html/nginx.conf;
我说过了,root在外面。
https://www.94cb.com/t/5672#Post26809
这是我目前完整的配置文件。
回复#8 @test2 :
server {
listen 80;
listen [::]:80;
server_name www.94cb.com 94cb.com m.94cb.com api.94cb.com cdn.94cb.com;
# 设置Carbon Forum路径
root /www/web/carbon/public_html;
index index.html index.php index.htm;
# 在这里引入Rewrite
include /www/web/carbon/public_html/nginx.conf;
# 转发PHP请求的php的cgi
location ~ \.php(.*)$ {
fastcgi_pass unix:/tmp/php-71-cgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $DOCUMENT_ROOT$fastcgi_script_name;
fastcgi_param PATH_INFO $2;
include fcgi.conf;
}
}这是目前官网在跑的Nginx上的配置,你参考下。
2018-05-09
#13
所以如果是二级目录的话,这么改就对了
...
server {
listen 80;
server_name localhost;
root /xxx/www;
index index.php index.html index.htm;
location /carbon/ {
try_files $uri $uri/ /carbon/index.php?$query_string;
}
}
... 登录后方可回帖

粤公网安备 44030602003677号
我和你同样的问题,我发现安装包的nginx.conf里就一句是
location / { try_files $uri $uri/ /index.php?$query_string; }# rewrite我记得以前的老版本有一堆规则
现在装5.9.0用哪种都是404了。。。