LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-13-2006, 08:09 PM   #1
dickohead
Member
 
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
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,148

Rep: Reputation: 236Reputation: 236Reputation: 236
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";
 
  


Reply

Tags
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/Novell 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


All times are GMT -5. The time now is 04:33 PM.

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