nginx隐藏入口文件index.php

网站的访问url可能是这样
http://www.xxx.com/index.php/home/index/index

这种有点不美观,我们想达到如下效果
http://www.xxx.com/home/index/index


修改一下nginx配置即可:

server {
  listen 80;
  server_name www.xxx.com;
  root "/var/html/wwwroot/xxx";
  index index.html index.php;
  location / {
    if (!-e $request_filename){
      rewrite ^(.*)$ /index.php?s=$1 last;
      break;
    }

  }
  # ...
}

posted on 2018-12-05 17:54  zqifa  阅读(1339)  评论(0编辑  收藏  举报

导航