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;
    }

  }
  # ...
}

出处:www.l1mn.com

原文标题:nginx隐藏入口文件index.php

原文地址:https://www.l1mn.com/p/php-rewrite-hidden-index.php.html

本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。

分类:服务器
评论

皖ICP备2023023451号

Copyright © L1MN.COM 联系方式:l1mnfw@163.com