标签:
ThinkPHP支持通过PATHINFO和URL rewrite的方式来提供友好的URL,只需要在配置文件中设置 ‘URL_MODEL‘ => 2 即可。在Apache下只需要开启mod_rewrite模块就可以正常访问了,但是Nginx中默认是不支持PATHINFO的,所以nginx默认情况下是不支持ThinkPHP的。不过我们可以通过修改nginx的配置文件来让其支持ThinkPHP。
虚拟主机配置文件: nginx/conf/vhost/127.0.0.1_8090.conf
server { listen 8090; server_name 127.0.0.1:8090; access_log logs/127.0.0.1_8090.access.log main; location / { root /www/jingchang/jck; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; break; } } location ~ \.php { root /www/jingchang/jck; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; set $real_script_name $fastcgi_script_name; 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; } }
Nginx 开启PATHINFO支持ThinkPHP框架实例
标签:
原文地址:http://www.cnblogs.com/52php/p/5683335.html