Home  >  Article  >  Backend Development  >  Solve the problems of not supporting pathinfo mode and various 404,500 problems under nginx+thinkphp

Solve the problems of not supporting pathinfo mode and various 404,500 problems under nginx+thinkphp

WBOY
WBOYOriginal
2016-08-08 09:21:48862browse

I have been working on the nginx environment problem for two days, and I found that many people's posts on the Internet either copied and pasted, or did not end up posting, and even wrote something like "Haha, I solved it myself". I despise these compatriots who posted this. Yes, you said you asked a question, but even after the problem was solved, you didn’t give an explanation. While you are still on the first few pages of the search, have you ever thought about the feelings of the people who need answers? I looked at the answer with joy and found that there was no knot. Okay, without further ado, let’s get to the point.

My method does not need to change the URL_Model to rewrite/compatible:

About line 43, follow the following to modify your own code, please pay attention to the detailed symbols:

location / {
                                                                                                           /Zend/workspaces; #//This is the root directory of your own project.
                                                                                                                                                                                                                         break;                                             In the php configuration, change location ~ .php$ to location ~ .php. Again, pay attention to details. The
$
symbol is removed here. I couldn't solve it at first because of this reason.

location ~ .php {
                                                                                                                                                                            fastcgi_param SCRIPT_FILENAME C:/wnmp/php$fastcgi_script_name; "";
set $ real_script_name $ fastcgi_script_name;
if ($ fastcgi_script_name ~ "^(.+? PHP) $") {

Set $ ​​Real_Script_name $ 1; e Set $ ​​PATH_INFO $ 2;

} FastCGI_PARAM Script_filename $ Document_root $ Real_Script_name; FastCgi_param Script_name $ Real_Script_name;仍}

If it is not resolved, add the configuration define ('_ php_file _', $ _ server ['script_name'] );

You may encounter problems with 500,404 during this period, but remember, just be careful. As long as you change it according to what I did, there will basically be no problem. If you still have questions, please leave a message for consultation.

Solution source reference: http://www.codesth.com/%E4%B8%8D%E7%94%A8rewrite%E5%85%BC%E5%AE%B9%EF%BC%8C%E8% A7%A3%E5%86%B3nginx%E4%B8%8D%E6%94%AF%E6%8C%81thinkphp-pathinfo%E6%A8%A1%E5%BC%8F/

The above introduces how to solve the problem of not supporting pathinfo mode and various 404,500 problems under nginx+thinkphp, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn