thinkphp nginx实现url pathinfo模式并隐藏url index.php
2015-01-21 18:31
609 查看
1.找到站点的.conf文件
如果不知道站点的.conf文件在哪可以用linux系统指令搜索举例:centos 6.5
find -name 站点名称.conf
2.编辑站点配置文件
vim 站点名称.conf
打开vim按键盘i键进入插入模式
server{ listen 80; server_name <span style="color:#33ff33;">url</span> <span style="color:#33ff33;">url</span>; root /a/domains/<span style="color:#33ff33;">站点文件夹</span>/public_html; index index.html index.htm index.shtml index.php; <span style="color:#ff0000;">if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } </span> error_page 404 /404.html; #Custom rules Start #Custom rules End location = /500.html { root /usr/share/nginx/html; } location <span style="color:#ff0000;">~ \.php(/.*)?$</span> { fastcgi_pass unix:/dev/shm/php.sock; include fastcgi_params; <span style="color:#ff0000;">#</span>fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; access_log /a/apps/nginx/logs/<span style="color:#33ff33;">url</span>.access.log main; <span style="color:#ff0000;">set $real_script_name $fastcgi_script_name; set $path_info ""; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info;</span> } location ~ /\.ht { deny all; } }
绿色部分每个人都不一样,红色部分就是需要修改部分。
修改完毕后vim按键盘esc按钮退出插入模式,输入ZZ退出保存文件,重启nginx。
结束
thinkphp版本3.2.x
相关文章推荐
- Nginx隐藏index.php和Pathinfo模式配置例子
- [PHP] url的pathinfo模式加载不同控制器的实现
- PHP url的pathinfo模式加载不同控制器的简单实现
- Yii 2 修改 URL 模式为 PATH 模式,并隐藏index.php
- nginx rewrite 隐藏index.php,利用pathinfo让url更友好
- thinkPHP如何将前台后台一起实现静态化,隐藏index.php,实现分组模式
- studyphp环境软件Nginx隐藏index.php和Pathinfo模式配置例子
- Nginx隐藏index.php和Pathinfo模式配置例子
- centos7 thinphp5 Nginx隐藏index.php和Pathinfo模式配置
- studyphp环境软件Nginx隐藏index.php和Pathinfo模式配置例子
- YII2 nginx配置pathinfo模式与隐藏入口index.php
- Nginx隐藏index.php和Pathinfo模式配置例子
- nginx配置pathinfo模式和隐藏index.php
- CI框架 .htaccess 隐藏url在index.php解决方案
- 如何在nginx环境中启用php的pathinfo URL模式[修正]
- nginx 404页面处理以及pathInfo和隐藏index.php总述
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- thinkphp隐藏中url的index.php
- apache服务器开启rewrite模式(隐藏index.php)
- 教你如何在CI框架中使用 .htaccess 隐藏url中index.php