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