nginx去掉url中的index.php

使用情境:我想输入www.abc.com/a/1后,实际上是跳转到www.abc.com/index.php/a/1


配置Nginx.conf在你的虚拟主机下加入:
location / {
     if (!-e $request_filename){
          rewrite ^/(.*)$ /index.php/$1 last;
     }
}


假设你的项目入口文件在一个子文件夹内。则:
location /文件夹/ {
     if (!-e $request_filename){
          rewrite ^/文件夹/(.*)$ /文件夹/index.php/$1 last;
     }
}

 

posted @ 2017-06-12 14:44  mfmdaoyou  阅读(338)  评论(0)    收藏  举报