问题原文
原帖链接 · Recif · CC BY-SA 4.0
My server is downloading only html files intead of serving them! Php files are served correctly. I've checked apache.conf and the mime type is correctly given :
AddType application/x-httpd-php .php
AddType application/x-httpd-phps .phps
AddType application/x-httpd-php7 .php7 .phtml
AddType application/x-httpd-php .html .htm
I've checked the file with the inline command : wge --server-response -O and header seems to be ok:
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Sat, 03 Sep 2022 17:22:52 GMT
Server: Apache/2.4.38
Last-Modified: Wed, 20 Jul 2022 16:31:05 GMT
Accept-Ranges: bytes
Content-Length: 2506
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/x-httpd-php
Length: 2506 (2.4K) [application/x-httpd-php]
Saving to: ‘/dev/null’
I'm searching for hours but can't find anything :-(
已采纳解答
原帖链接 · vidarlo · CC BY-SA 4.0
You claim html is application/x-httpd-php. It isn't. It's text/html.
Your browser doesn't know how to display application/x-httpd-php; it knows how to display text/html. You need to send the correct mime type for the browser to display it. If the browser doesn't know how to display mime type sent by the server, it will default to offering to save the file to disk.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
