nginx配置后只有根目录首页index.php能访问,其他页面404

被刻印的时光 ゝ 提交于 2019-11-27 20:44:38

我本地是window系统,用的是phpstudy,解决办法:用phpstudy点击其他选项菜单->打开配置文件->选择vhost-ini(或者找到nginx安装目录,打开vhost.conf),在你的站点配置里

location / {
  index index.html index.htm index.php;
  #autoindex on;
}

改为

location / {
  index index.html index.htm index.php;
  try_files $uri $uri/ /index.php?$query_string;
  if (!-e $request_filename){
    rewrite ^/(.*) /index.php last;
  }
  #autoindex on;
}

最后重启nginx,就搞定了。

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!