1. Modify the thinkphp configuration file
Open file, project root directory/app/home/conf/config.php
' Url_model '=1, //URL set to pathinfo mode
2. Modify the Nginx configuration file under Linux
/etc/nginx/nginx.conf
server{......location~\.php {root/www/; Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php;fastcgi_param script_filename $document _root$fastcgi_script_name;include fastcgi_ params, #定义变量 $path _info for storing pathinfo informationSet$path _info""; #定义变量 $real _script_name, for storing real addressesSet$real _script_name $fastcgi _script_name; #如果地址与引号内的正则表达式匹配if($fastcgi _script_name ~"^ (. +?\.php) (/.+) $") {#将文件地址赋值给变量 $real _script_nameSet$real _script_name $1; #将文件地址后的参数赋值给变量 $path _infoSet$path _info $2;} #配置fastcgi的一些参数fastcgi_param script_filename $document _root$real_script_name;fastcgi_param script_name $real _ Script_name;fastcgi_param path_info $path _info;} ......}
3. Restart Nginx Service
Run the following command
Service Nginx Restart
thinkphp How to configure the URL mode to PathInfo?