2

I'm doing PHP get_headers() on an mp3 file on my server and receive HTTP 404 when using the non-www address and HTTP 200 when using www.

I can access the file from either address in the browser, so why the 404? Can I fix this somehow with .htaccess?

1) WordPress is configured to use the non-www address (example.com)

2) The files are in the wp-content/uploads area of the WordPress install

3) The www subdomain has a DNS CNAME pointing to the non-www domain (www.example.com -> example.com)


Headers for: 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

Headers for: 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
Frankie Jarrett
  • 494
  • 7
  • 11

1 Answers1

1

The fact that www.example.com and example.com point to the same IP address via a DNS CNAME entry doesn't mean that the server is configured to serve both. This server could be configured to handle a multitude of HTTP hosts and the default might not be www.example.com but something else. It would in fact be unsurprising behaviour that it returns a 404 status for a host for which it's not configured (not even a default host).

Check that there is a VirtualHost entry in your Apache Httpd configuration for each of www.example.com and example.com. The fact that Wordpress is configured for a particular host only comes into play after having passed that step.

Bruno
  • 119,590
  • 31
  • 270
  • 376