Forum Moderators: coopster
AddType application/x-httpd-php .css
can't be used because of the way suphp is set up and that I have to use a php.ini file. However, after hours of searching, I can't find the syntax required to create this php.ini file, and to get it to parse other extensions such as .html .css .foo .etc
Anyone have exerience with this & can show me the syntax?
Seriously, the php.ini file is only going to get invoked if the PHP parser is invoked, so it's too late in the stream to do anything about telling Apache how to handle files with a .css extension. Those directives must be set in either the httpd.conf file (Apache settings) or the .htaccess file.
Tom
What other options are there? I will send off an email to the "high level" tech guys there and see...
Why are you attempting to parse a .CSS file through PHP?
If you need custom style settings based on PHP variables, you should use the PHP to load a specific .CSS file or to make modifications to style instructions after the primary .CSS file has loaded through a combination of Javascript and the PHP variables.
I know it seems like writing a remote .CSS file using PHP and the including it normally might work, but .CSS files and PHP files have different header data which is messing with you. The server is already instructed in how to post files with a .CSS extension (text/css), so changing those headers by writing the file with PHP probably breaks one or the other.
The often overlooked issue is that PHP enabling CSS files prevents them being cached by the browser, which is half the point of external CSS in the first place! However, if you're prepared to split your CSS into static and dynamic files, with appropriate folder level .htaccess files, it shouldn't be a problem.
PHP enabling CSS files prevents them being cached by the browser
How so? The page is compiled and delivered the same as a non-compiled page, i.e.:
<link rel="stylesheet" type="text/css" href="style.css"> ends up on the page and makes the request regardless of whether the page was compiled or not, doesn't it?
Thanks.
HTTP/1.0·200·OK(CR)
(LF)
Date:·Fri,·12·Nov·2004·22:28:57·GMT(CR)
(LF)
Server:·Apache/1.3.27·(Unix) ... PHP/4.3.2 ... (CR)
(LF)
Last-Modified:·Thu,·28·Oct·2004·23:11:27·GMT(CR)
(LF)
ETag:·"36412c-b6a-41817c9f"(CR)
(LF)
Accept-Ranges:·bytes(CR)
(LF)
Content-Length:·2922(CR)
(LF)
Connection:·close(CR)
(LF)
Content-Type:·text/css(CR)
With a PHP parsed CSS file (with a text/css header):
HTTP/1.1·200·OK(CR)
(LF)
Date:·Fri,·12·Nov·2004·22:27:01·GMT(CR)
(LF)
Server:·Apache/1.3.27·(Unix) ... PHP/4.3.2 ... (CR)
(LF)
X-Powered-By:·PHP/4.3.2(CR)
(LF)
Connection:·close(CR)
(LF)
Content-Type:·text/css(CR)
I'd imagine that the lack of Content-Length and Last-Modified headers would be the critical differences.
AddType x-httpd-php .css
instead of:
AddType application/x-httpd-php .css
Couldn't tell you why this works. I'm not an apache guru. Now to worry about/understand the caching issue...