: This article mainly introduces the research on SSI in nginx. if you are interested in the PHP Tutorial, refer to it. Recently, I feel quite comfortable. this project team does not have any specialized PHP team. I was the first to come in for PHP (and of course there is a front-end). haha, I will design and modify the PHP framework suitable for our business. haha, I feel like I will learn a lot. I spoke about the php framework in front of more than 20 seniors in the group a few days ago, I also want to discuss with the experts about the php framework suitable for us. I feel that my ability to express myself is too bad and I don't know what I know. I also want my mentor to help me express it, here, I would like to thank my mentor Yu Honglei (for short). I have never seen such a deep programmer and I am sure that I am a technology engineer, my understanding of technology is beyond my imagination. I read a lot of books and have a wide range of books, especially in history and literature, I have been talking about it for many days. I am humorous and often cite a few articles from time to time! I really don't feel like a tech-savvy guy. he is more like Luo Yonghao. haha, in the past two years, he has been my goal. he has read more books and spoken more to improve his ability to express himself, otherwise, you will not be able to share what you know through the most direct expression, which is depressing.
Let's get started with this question. today we are going to talk about an SSI question. here we will first introduce SSI.
SSI is the abbreviation of Server Side Inclde, which means that the Server contains the meaning. All I want to talk about today is to use the include command of the SSI module in nginx. this command will contain a page, then expand it in the nginx server.
What problems do I encounter? Now there is a rich text editing editor that requires you to save the page, enter some html (including the SSI include command), save it in the database, and edit it after saving it, the content in the rich text editor must be as follows:
Hello World!!!
The problem is here, where the ssi command is included.
Only Hello World !!!, Configure nginx as follows:
ssi on;ssi_types text/html;
At this time, if data of the mime type text/shtml type is passed through nginx, nginx will go back to parse these commands, which leads to a problem, an error occurs when I find the data in the database and return it to the rich text editor of the client. The echo content is as follows:
This form is displayed on the page:
I am a little depressed, because other functions on the server must use ssi, and I don't need it here. what should I do?
At this time, I thought of ssi_types. Here we set text/html, and there is also a commonly used text/plain. What is this mime type, in the browser, he will display all the content intact without parsing html and css. With this type, nginx will not be expanded. try to modify the mime before the output:
header('Content-type: text/plain');
Sure enough, after the mime is modified, the output is the same as that in the database, and it cannot be changed:
It seems that the problem has been solved, but I did not expect that due to historical reasons, the content in the background editing box and other content are returned together, if all text and plain content is displayed in the browser, the problem remains unsolved ~~
In this case, the nginx configuration should be considered. because the files to be parsed and expanded by nginx are generally suffixed with shtml, html, and so on, the database query is generally php, so I can narrow down the file used by ssi to the file with the suffix shtml and html to see the configuration. here I will talk about the ssi configuration information moving to a match, let's look at the effect,
location ~* \.(html|shtml|htm)$ { ssi on; ssi_types text/shtml; proxy_pass http://www.testssi.com; }
Create html and PHP files with similar content,
';echo '
';echo '
';echo 'TEst!!';
Html:
TEst!!
Only Test! is output for php access !!, For other content, you can view the source code. in html, the system parses the content of the contained file and reports an error !! Now the problem is basically solved. we should try this method after work next week. it should be okay during the test.
The copyright of this article is owned by the author iforever (luluyrt@163.com), without the author's consent to prohibit any form of Reprint, Post reprinted article must be in the obvious position of the article page to give the author and the original article connection.
The above introduces the research on SSI in nginx, including some content, and hopes to help friends who are interested in PHP tutorials.