首页 > 教程 >
nginx隐藏index.php的设置方法
2023-02-17教程围观次
简介nginx隐藏index.php的设置方法在访问http://php.cc/Att/AttList的时候、跳转到http://php.cc/index.php/Att/AttList;也就是开启重写功能;在nginx配置文件nginx.conf中添加:location/{if(!e$request_filename){rewrite^/(.*)$/index.php/$1last;}}如果项目入口
nginx 隐藏index.php的设置方法
在访问 http://php.cc/Att/AttList 的时候、跳转到http://php.cc/index.php/Att/AttList ;
也就是开启重写功能;
在nginx配置文件nginx.conf中添加:
location / { if ( !e $request_filename ) { rewrite ^/(.*)$ /index.php/$1 last; }}
如果项目入口文件是在一个子目录里面,则如下:
location / { if ( !e $request_filename ) { rewrite ^/目录/(.*)$ /目录/index.php/$1 last; }}
切记:不可以出现两个location / {}、否则nginx服务器将启动不了;
我的配置文件如下:
server { listen 80; server_name www.baidu.com baidu.com; root "D:/abc/php"; location / { if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?$1 last; } index index.html index.htm index.php; autoindex on; } location ~ .php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+.php)(/?.+)$; fastcgi_param _FILENAME $document_root$fastcgi_ _name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; }}
其中:
autoindex on; 是打开nginx的浏览目录的功能;
下载链接:网站源码/小程序源码/网站模板下载
下载排行
最新发布
-
最新去水印小程序源码分享/无需后台/对接接口/支持全网去水印功能
-
群多多社群人脉H5-2.1.4多开插件+小程序独立前端+搭建教程
-
七夕情侣飞行棋游戏限定版本源码/解锁版
-
苹果CMS海螺模版V20修复版/加广告代码
-
宠物社区风格 商业版(GBK)Discuz模板
-
全新UI基于Thinkphp的最新自助打印系统/云打印小程序源码/附教程
-
易优CMS家纺家居装饰类网站模板/EyouCMS家具家居类企业网站模板
-
EyouCMS艺术***摄影工作室网站模板/易优CMS摄影工作室网站模板
-
易优CMS响应式精品茶具实木茶盘销售网站模板/EyouCMS响应式酒水饮料类企业网站模板
-
EyouCMS响应式推土机挖掘机机械类网站模板/易优CMS机械设备类企业网站模板