不灭的焱

加密类型:SHA/AES/RSA下载Go
复合类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel)、接口(interface)、数组(array)、结构体(struct) Go类型+零值nil
引用类型:切片(slice)、映射(map)、指针(pointer)、函数(function)、通道(channel) Go引用

作者:AlbertWen  添加时间:2016-04-17 22:17:00  修改时间:2025-12-11 16:05:21  分类:12.PHP库/系统  编辑

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