In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to support ThinkPHP's Pathinfo and URl Rewrite mode under Nginx. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
1. ThinkPHP provides the official solution for ThinkPHP, as follows:
Location ~ .php {# original code # defines the variable $path_info to store pathinfo information set $path_info "; # defines the variable $real_script_name to store the real address set $real_script_name $fastcgi_script_name # if the address matches the regular expression in quotation marks if ($fastcgi_script_name ~ "^ (. +?\ .php) (/. +) $") {# assign the file address to the variable $real_script_name set $real_script_name $1 # assign the parameter after the file address to the variable $path_info set $path_info $2;} # configure some parameters of fastcgi fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name Fastcgi_param PATH_INFO $path_info;}
In this way, the nginx server can support pathinfo. However, if you want to support the mode with URL_MODE set to 2 for ThinkPHP, you also need to configure rewrite rules. Locate the access_log statement and add the following statement above it:
# if the request is neither a file nor a directory, execute the rewriting rule if (!-e $request_filename) {# address as the parameter rewrite to the index.php. Rewrite ^ (. *) $/ index.php?s=$1 last; # if it is a subdirectory, use the following sentence to change subdir to the directory name. # rewrite ^ / subdir/ (. *) $/ subdir/index.php/$1;}
2016.09
After reading the above, do you have any further understanding of how ThinkPHP's Pathinfo and URl Rewrite modes are supported under Nginx? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.