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


我本地是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,就搞定了。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM