Thinkphp supports PATHINFO in earlier Nginx versions. nginxpathinfo_PHP tutorial

Source: Internet
Author: User
Thinkphp supports PATHINFO in earlier versions of Nginx, nginxpathinfo. Thinkphp supports PATHINFO sharing in earlier versions of Nginx. nginxpathinfo recently used thinkphp for a project, after deployment to the nginx server, we found that nginx does not support thinkphp and supports PATHINFO in earlier Nginx versions. nginxpathinfo

I recently used thinkphp to build a project. after deployment to the nginx server, I found that nginx does not support pathinfo. how can I deal with it.

Nginx environment

In earlier versions of Nginx, PATHINFO is not supported. However, in Nginx. conf (in/usr/local/nginx/conf/nginx. conf or use find/| grep nginx. configure the forwarding rule implementation in the nginx configuration file:

location / { if (!-e $request_filename) {   rewrite ^(.*)$ /index.php?s=$1 last;   break; }} 

In fact, the URL is forwarded to the compatible mode provided by ThinkPHP. this method can be used to solve other WEB server environments that do not support PATHINFO.
If your ThinkPHP is installed in the second-level Directory, set the pseudo-static method of Nginx as follows, where youdomain is the directory name.

location /youdomain/ { if (!-e $request_filename){  rewrite ^/youdomain/(.*)$ /youdomain/index.php?s=$1 last; }} 

For example:

location /thinkphp/ { if (!-e $request_filename){    rewrite ^/thinkphp/(.*)$ /thinkphp/index.php?s=$1 last; }}

Syntax: rewrite regex replacement flag (last is equivalent to the [L] Mark in apache, indicating rewrite .)

PATHINFO is supported under idea. nginxpathinfo recently used thinkphp to build a project. after deployment to the nginx server, nginx is not supported...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.