lnmp1.2 supports thinkphp pathinfo and rewrite

Source: Internet
Author: User

First, PathInfo support method

1.2 Version of the system has automatically generated a pathinfo configuration file, but the actual measurement is not available, so we first find this file and modify its contents, the file path is:/usr/local/nginx/pathinfo.conf, the content is modified as follows:

Set $path _info ""; #定义变量 $real _script_name for storing the real address set $real _script_name $fastcgi _script_name; #如果地址与引号内的正则表达式匹配if ($ Fastcgi_script_name ~ "^ (. +?\.php) (/.+) $") {#将文件地址赋值给变量 $real _script_nameset $real _script_name $; #将文件地址后的参数赋值给变量 $ Path_infoset $path _info;} #配置fastcgi的一些参数fastcgi_param script_filename $document _root$real_script_name;fastcgi_param script_name $real _ Script_name;fastcgi_param path_info $path _info;

Then find your own configuration file to support the PathInfo Web site, the file path is:/user/local/nginx/vhost/**.conf, found in the file "#include pathinfo.conf;" This line, will be # removed.

Restart Nginx, the command is:/etc/init.d/nginx Restart, after the successful restart can use PathInfo way to access the site.

Second, add rewrite support method

Locate the configuration file to support the Web site, the file path is:/user/local/nginx/vhost/**.conf, if the host was created when the rewrite configuration file has been set, then directly modify the previously selected configuration file, no, You can create a new other.conf rewrite profile that can be used directly by other sites later.

In the configuration file, locate the "root/home/wwwroot/your site root", this code, and then add an "include other.conf;" in the following sentence.

Return nginx configuration Directory "/usr/local/nginx/conf/", if there is already exist other.conf directly overwrite the contents of the content, does not exist the new.

The contents of the other.conf are as follows:

Location/{        if (!-e $request _filename) {                rewrite ^ (. *) $/index.php/$1;         }}

Restart Nginx, "/etc/init.d/nginx restart", re-visit the site can be omitted index.php.

lnmp1.2 supports thinkphp pathinfo and rewrite

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.