Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming...
URL rewrite method
Server {listen 8080; server_name www.xxx.com; root/Users/lch/work/www/ci; access_log/usr/local/var/log/access. log; error_log/usr/local/var/log/error. log; location ~ ^/(Img | images | script | js | css | upload)/{root/Users/lch/work/www/ci; break;} location ~ {If (! -E $ request_filename) {# for/admin rewrite ^/(admin) $/index. php? C = welcome & m = index & d = $1 break; # for/admin/index rewrite ^/(admin)/([a-zA-Z _] +) $/index. php? C = $2 & m = index & d = $1 break; # for/admin/account/login rewrite ^/(admin +) /([a-zA-Z _] +)/([a-zA-Z _] +) $/index. php? C = $2 & m = $3 & d = $1 break; ## for general URL rewrite ^/([a-zA-Z _] +) /([a-zA-Z _] + )/? (. *) $/Index. php? C = $1 & m = $2 last;} root/Users/lch/work/www/ci; fastcgi_pass 127.0.0.1: 9001; fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name; include fastcgi_params ;}}
Description of the above configuration, because I created a folder named admin in application/controllers/to store the controller related to the background, therefore, it is more than a common path (corresponding to & d = admin. Here we can see that the rewrite method is insufficient. when there is a situation like admin, we need to add the corresponding rewrite rule.
PATH_INFO method
Server {listen 8080; server_name www.xxx.com; root/Users/lch/work/kidulty/snap_www; access_log/usr/local/var/log/snap_access.log; error_log/usr/local/var/log/snap_error.log; location ~ ^/(Img | images | script | js | css | upload)/{root/Users/lch/work/kidulty/snap_www; break;} if (! -E $ request_filename) {rewrite ^ (. *) $/index. php/$1 last;} location ~ {Set $ path_info ""; set $ real_script_name $ fastcgi_script_name; if ($ fastcgi_script_name ~ "^ (. +? \. Php )(/. +) $ ") {set $ real_script_name $1; set $ path_info $2;} root/Users/lch/work/kidulty/snap_www; fastcgi_pass 127.0.0.1: 9001; fastcgi_index index. php; fastcgi_param SCRIPT_FILENAME $ document_root $ real_script_name; fastcgi_param SCRIPT_NAME $ real_script_name; fastcgi_param PATH_INFO $ path_info; include fastcgi_params ;}}
Note:
If the project URL is similar to http://www.xxx.com/index.php/user/profile, the following rewrite:
If (! -E $ request_filename) {rewrite ^ (. *) $/index. php/$1 last ;}
The above is the content of CodeIgniter Project (2) configured in Nginx. For more information, see PHP Chinese network (www.php1.cn )!