【发布时间】:2012-05-17 08:34:42
【问题描述】:
我正在服务器上的 mp3 文件上执行 PHP get_headers(),并在使用非 www 地址时接收 HTTP 404,在使用 www 时接收 HTTP 200。
我可以从浏览器中的任一地址访问该文件,那为什么是 404?我可以用 .htaccess 以某种方式解决这个问题吗?
1) WordPress 配置为使用非 www 地址 (example.com)
2) 文件位于 WordPress 安装的 wp-content/uploads 区域中
3) www 子域有一个 DNS CNAME 指向非 www 域 (www.example.com -> example.com)
标题:http://lhcsj.org/wp-content/uploads/2012/05/2012-5-6-sj.mp3
HTTP/1.1 404 Not Found
Date: Tue, 08 May 2012 21:11:43 GMT
Server: Apache/2.2.3 (CentOS)
Content-Length: 314
Connection: close
Content-Type: text/html; charset=iso-8859-1
标题:http://www.lhcsj.org/wp-content/uploads/2012/05/2012-5-6-sj.mp3
HTTP/1.1 200 OK
Date: Tue, 08 May 2012 21:08:05 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Mon, 07 May 2012 17:19:47 GMT
ETag: "9c52430-e3626f-7a1332c0"
Accept-Ranges: bytes
Content-Length: 14901871
Connection: close
Content-Type: audio/mpeg
【问题讨论】:
-
您在尝试访问您的 mp3 文件或页面时遇到了 HTTP 404?究竟是什么日志?
-
好的,我已经添加了为每个文件 URL 返回的标题
-
嗯,当我调用
get_headers('http://lhcsj.org/wp-content/uploads/2012/05/2012-5-6-sj.mp3')时,我得到了 HTTP 200 -
@pier-alexandre-bouchar 我只是使用WordPress生成的默认htaccess:codex.wordpress.org/…
-
@anubhava 我想知道我在与文件相同的服务器上使用 get_headers() 是否会有所不同?
标签: wordpress http .htaccess dns http-status-code-404