[wp-hackers] Getting a 404 error when requesting a .php file as a stylesheet in WP 3.0.1

David Morris dvmorris at gmail.com
Sat Sep 4 01:29:42 UTC 2010


I just upgraded a site from WPMU 2.9.1 to WP 3.0.1, and I'm getting a
strange issue with a PHP file that is being served up as text/css throwing a
404. It's part of a theme that runs PHP code to create a dynamic stylesheet.

Anyways, the file is called custom-styles.php and is requested on page load
through a <link rel="stylesheet" /> tag. I'm getting a 404 whenever it's
requested this way, but when I go to that URL directly in the browser, it
seems to work fine. Here are the request and response headers for the <link>
tag:

URL: http://example.com/wp-content/themes/theme_name/custom-styles.php
Request Headers:


   1. Accept:
      text/css,*/*;q=0.1
      2. Cache-Control:
      max-age=0
      3. Referer:
      http://example.com/
      4. User-Agent:
      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4
      (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4

Response Headers:


   1. Cache-Control:
      no-cache, must-revalidate, max-age=0
      2. Connection:
      close
      3. Content-Length:
      6184
      4. Content-Type:
      text/css; charset=UTF-8
      5. Date:
      Sat, 04 Sep 2010 01:10:55 GMT
      6. Expires:
      Wed, 11 Jan 1984 05:00:00 GMT
      7. Last-Modified:
      Sat, 04 Sep 2010 01:10:55 GMT
      8. Pragma:
      no-cache
      9. Server:
      Apache/2.2.3 (Red Hat)
      10. X-Pingback:
      http://example.com/xmlrpc.php
      11. X-Powered-By:
      PHP/5.2.11


When I request that URL directly in the browser, I get a 404, but the proper
content seems to be served up. These are my headers:

URL: http://example.com/wp-content/themes/theme_name/custom-styles.php
Request Headers:



   1. Accept:

      application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
      2. User-Agent:
      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4
      (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4

Response Headers:



   1. Cache-Control:
      no-cache, must-revalidate, max-age=0
      2. Connection:
      close
      3. Content-Length:
      6184
      4. Content-Type:
      text/css; charset=UTF-8
      5. Date:
      Sat, 04 Sep 2010 01:20:27 GMT
      6. Expires:
      Wed, 11 Jan 1984 05:00:00 GMT
      7. Last-Modified:
      Sat, 04 Sep 2010 01:20:27 GMT
      8. Pragma:
      no-cache
      9. Server:
      Apache/2.2.3 (Red Hat)
      10. X-Pingback:
      http://example.com/xmlrpc.php
      11. X-Powered-By:
      PHP/5.2.11


Then when I request that same file with a www. prefix, it seems to serve up
the content and a 200 response code:

 URL: http://www.example.com/wp-content/themes/theme_name/custom-styles.php
 Request Headers:


   1. Accept:

      application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
      2. User-Agent:
      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.4
      (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4

 Response Headers:


   1. Content-Length:
      6184
      2. Content-Type:
      text/css; charset=UTF-8
      3. Date:
      Sat, 04 Sep 2010 01:19:45 GMT
      4. Server:
      Apache/2.2.3 (Red Hat)
      5. X-Pingback:
      http://example.com/xmlrpc.php
      6. X-Powered-By:
      PHP/5.2.12



I would send the real domain, but it's in an environment inside an internal
network, so it wouldn't work anyway. I realize this may have nothing to do
with wordpress, and may just be an Apache issue, but these files work
perfectly fine on the same server, same apache configs, with 2.9.1 code
running instead of 3.0.1. Let me know if you guys have any ideas. Thanks for
your help,

Dave


More information about the wp-hackers mailing list