Saving an HTML file to a file (such as test.aaa) with a suffix of AAA (or any other format), and then opening it in a browser, finds that the browser cannot be displayed as a Web page, but instead displays the HTML source in the TEST.AAA.
And if it is saved as: test.html, it is normal in the webpage.
For example: in the root directory of the Web site, there are 2 files: test.html and TEST.AAA
The code is as follows:
Access results:
http://127.0.0.1/test.aaa
==> Display Web page source code
http://127.0.0.1/test.html
==> Display a button
Question: How can a browser display a file in any format as a Web page?
Reply content:
Saving an HTML file to a file (such as test.aaa) with a suffix of AAA (or any other format), and then opening it in a browser, finds that the browser cannot be displayed as a Web page, but instead displays the HTML source in the TEST.AAA.
And if it is saved as: test.html, it is normal in the webpage.
For example: in the root directory of the Web site, there are 2 files: test.html and TEST.AAA
The code is as follows:
Access results:
http://127.0.0.1/test.aaa
==> Display Web page source code
http://127.0.0.1/test.html
==> Display a button
Question: How can a browser display a file in any format as a Web page?
Set HTTP header to Content-Type: text/html
.
In addition, this should be related to your Web service area and it has nothing to do with PHP, for example, if you use Nginx, you have to .aaa
change the suffix of the filename corresponding to the MIME Type text/html
.