-   Programming (
-   -   Apache parsing css files for php scripting. (

dickohead 09-13-2006 08:09 PM

Apache parsing css files for php scripting.
Hey folks,

I have a few pages setup where I need to run php scripts inside my css files. But only a few...

So for apache.conf I have added that it should parse css files as php, and for the css files with php in them, I have added the header accordingly. Now that's great for the few sites that need this, but the changes in apache.conf are system wide, so now ALL css files need that header added to them.... there's a lot of css files!

For the few pages that need CSS, can I just do a <link rel="stylesheet" href="styles.php" /> rather than styles.css? That way I can remove the parsing of css files from apache.conf....

Or how would I restrict the apache.conf file to only apply the css settings to certain folders?

Guttorm 09-14-2006 04:40 AM


If you use virtual hosting with Apache, you can just add a

AddType application/x-httpd-php .css
inside the <VirtualHost> section, but you will get PHP parsing for all .css files on that domain.

Another way is to turn it off completely, and instead of refering to the .css files, put it inline in the page. So instead of using


<link rel="stylesheet" href="cssfile.css">
Use tags like:


<style type="text/css">
/* The CSS goes in here */

Using PHP - it can be like:

echo "<style type=\"text/css\">\n";
echo "<!--\n";
echo "-->\n";
echo "</style>\n";

All times are GMT -5. The time now is 06:09 AM.