By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,129 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,129 IT Pros & Developers. It's quick & easy.

configure apache to recognize php in css files

P: n/a
Hi folks,

I have a website with linked CSS files controlling layout, via LINK
tags. In these linked CSS files, I need to create dynamic styles. This
is a website of articles, and for every article type in the MySQL
database, I need another style.

..article-type-0{color:red;}
..article-type-1{color:red;} etc.

I could use PHP in the HTML head to write styles, but I'm using the
media attribute of the LINK tag to control which styles go to which
output devices. Therefore, I'd like to use PHP to author a linked CSS
file.

Being an idiot, I had figured I could update my httpd.conf file (apache
2/redhat 8) and rewrite an AddType line to read:

AddType application/x-httpd-php .php .htm .html .css

It kind of worked. Almost. In fact, calling up the CSS in a browser
window showed that PHP did take over when asked and wrote my
article-type classes into the right places, using valid CSS.

However, once I did that, the web pages displayed as though no CSS file
were present.

Which tweak to httpd.conf or php.ini do I need to get PHP function in a
linked CSS file?

Thanks,
-Dan

Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
dm*******@yahoo.com wrote:
Hi folks,

I have a website with linked CSS files controlling layout, via LINK
tags. In these linked CSS files, I need to create dynamic styles. This
is a website of articles, and for every article type in the MySQL
database, I need another style.

.article-type-0{color:red;}
.article-type-1{color:red;} etc.

I could use PHP in the HTML head to write styles, but I'm using the
media attribute of the LINK tag to control which styles go to which
output devices. Therefore, I'd like to use PHP to author a linked CSS
file.

Being an idiot, I had figured I could update my httpd.conf file (apache
2/redhat 8) and rewrite an AddType line to read:

AddType application/x-httpd-php .php .htm .html .css

It kind of worked. Almost. In fact, calling up the CSS in a browser
window showed that PHP did take over when asked and wrote my
article-type classes into the right places, using valid CSS.

However, once I did that, the web pages displayed as though no CSS file
were present.
Maybe this works: Put

<?php
header("Content-Type: text/css");
?>

at the top of every .css file, so that the browser knows that it's
dealing with a CSS stylesheet.

Which tweak to httpd.conf or php.ini do I need to get PHP function in a
linked CSS file?

Thanks,
-Dan

Jul 17 '05 #2

P: n/a

Dani CS wrote:
dm*******@yahoo.com wrote:
Hi folks,

I have a website with linked CSS files controlling layout, via LINK
tags. In these linked CSS files, I need to create dynamic styles. This is a website of articles, and for every article type in the MySQL
database, I need another style.

.article-type-0{color:red;}
.article-type-1{color:red;} etc.

I could use PHP in the HTML head to write styles, but I'm using the
media attribute of the LINK tag to control which styles go to which output devices. Therefore, I'd like to use PHP to author a linked CSS file.

Being an idiot, I had figured I could update my httpd.conf file (apache 2/redhat 8) and rewrite an AddType line to read:

AddType application/x-httpd-php .php .htm .html .css

It kind of worked. Almost. In fact, calling up the CSS in a browser
window showed that PHP did take over when asked and wrote my
article-type classes into the right places, using valid CSS.

However, once I did that, the web pages displayed as though no CSS file were present.


Maybe this works: Put

<?php
header("Content-Type: text/css");
?>

at the top of every .css file, so that the browser knows that it's
dealing with a CSS stylesheet.

Which tweak to httpd.conf or php.ini do I need to get PHP function in a linked CSS file?

Thanks,
-Dan


That worked exceptionally well.

Much appreciated,
-Dan

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.