PHP: html display of any file format

Source: Internet
Author: User
Save an html file as a file with the suffix aaa (or any other format) (for example, test. aaa), and when opened in the browser, it is found that the browser cannot be displayed in the form of a webpage, but test. the html source code in aaa is displayed. If it is saved as test.html... save an html file as a file with the suffix aaa (or any other format) (for example, test. aaa), and when opened in the browser, it is found that the browser cannot be displayed in the form of a webpage, but test. the html source code in aaa is displayed.
If it is saved as test.html, it is normal on the webpage.
For example, there are two files under the root directory of the Website: test.html and test. aaa.
The Code is as follows:


  

Access results:
http://127.0.0.1/test.aaa==> Display webpage source code
http://127.0.0.1/test.html==> Display a button
Q: How can a Browser display files in any format on a webpage?

Reply content:

Save an html file as a file with the suffix aaa (or any other format) (for example, test. aaa), and when opened in the browser, it is found that the browser cannot be displayed in the form of a webpage, but test. the html source code in aaa is displayed.
If it is saved as test.html, it is normal on the webpage.
For example, there are two files under the root directory of the Website: test.html and test. aaa.
The Code is as follows:


  

Access results:
http://127.0.0.1/test.aaa==> Display webpage source code
http://127.0.0.1/test.html==> Display a button
Q: How can a Browser display files in any format on a webpage?

Set http headerContent-Type: text/html.

In addition, this should be related to your web service area, but it has nothing to do with php. For example, if you use nginx, you have.aaaChange the MIME Type corresponding to the suffix file nametext/html.

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.