nginx隐藏入口文件index.php

Posted zqifa

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
    }

  }
  # ...
}

以上是关于nginx隐藏入口文件index.php的主要内容,如果未能解决你的问题,请参考以下文章