Recently in the use of thinkphp to do a project, basically completed after deployment to the Nginx server to find that Nginx is not support pathinfo so how do we deal with it.
Nginx Environment
In the Nginx version, the pathinfo is not supported, but can be passed in nginx.conf (in/usr/local/nginx/conf/nginx.conf or through Find/| grep nginx.conf to find locations) Configure the forwarding rule implementation: Add in the Nginx configuration file:
Location/{
if (!-e $request _filename) {
rewrite ^ (. *) $/index.php?s=$1 last;
break;
}
}
In fact, the internal is forwarded to the thinkphp provided by the compatibility mode of the URL, in this way, you can resolve other unsupported PathInfo Web server environment.
If your thinkphp is installed in level two directory, Nginx's pseudo static method is set as follows, where Youdomain is the directory name.
location/youdomain/{
if (!-e $request _filename) {
rewrite ^/youdomain/(. *) $/youdomain/index.php?s=$1 last;
}
}
Such as:
location/thinkphp/{
if (!-e $request _filename) {
rewrite ^/thinkphp/(. *) $/thinkphp/index.php?s=$1 last;
}
}
Syntax: Rewrite regex replacement flag (last equivalent to the [L] tag inside Apache, representing rewrite. )