Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-13-2006, 08:09 PM   #1
Registered: Feb 2003
Location: Melbourne, VIC, Australia
Distribution: Ubuntu 6.06
Posts: 101

Rep: Reputation: 15
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?

Last edited by dickohead; 09-13-2006 at 08:11 PM.
Old 09-14-2006, 04:40 AM   #2
Senior Member
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,333

Rep: Reputation: 362Reputation: 362Reputation: 362Reputation: 362

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";


apache, apacheconf, css, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache 2, PHP 5, SuSE 9.2 - cannot run php files dickohead Linux - Networking 6 06-28-2006 10:25 AM
Parsing PHP Scripts using Apache in SuSe 9.3 (without a dedicated server) elliotfuller SUSE / openSUSE 7 07-27-2005 11:40 AM
Apache-ssl not correctly parsing php files jme Linux - Software 2 05-03-2005 12:04 PM
php files errors on apache - sometimes amimusa Debian 1 04-07-2005 12:52 PM
running apache/php files limp Programming 3 11-07-2004 08:10 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration