大网数据广告活动
服务器运维问答

Apache downloading html files instead of serving them, php file working

· 52CE 我爱测

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-php…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-09-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。