LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Apache parsing css files for php scripting. (http://www.linuxquestions.org/questions/programming-9/apache-parsing-css-files-for-php-scripting-483282/)

dickohead 09-13-2006 09: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 05:40 AM

Hi

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

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

Code:

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

Code:

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


Using PHP - it can be like:
Code:

echo "<style type=\"text/css\">\n";
echo "<!--\n";
include('cssfile.css');
echo "-->\n";
echo "</style>\n";



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