Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7781771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:20:04+00:00 2026-06-01T19:20:04+00:00

I have a very interesting problem related to Deflate Compression, Apache (htaccess), and CSS

  • 0

I have a very interesting problem related to Deflate Compression, Apache (htaccess), and CSS files.

I have two CSS files on my server. One is called styles.php and has dynamic values added based on database values through mod_rewrite in the styles/ directory (it is rewritten from styles.php to site.css and there is a text/css header at the beginning of the file). I also have a regular old css file with static content that doesn’t change in the same directory called styles.css.

I’ve wanted to add compression to my site so I added the following line to start compressing my css and js files. I added this to the root_directory for my website.

<ifModule mod_deflate.c>
    <filesMatch "\.(js|css)$">
        SetOutputFilter DEFLATE
    </filesMatch>
</ifModule>

Well initially that didn’t work. So I changed this line in the root htaccess file from this to the next thing. (this code below is located at the top of the file)

AddType application/x-httpd-php5 .html .php
AddType application/x-httpd-php5 .html .php .js .css

Then my js and one of the css files started to be compressed (verified with YSlow…..yay!). The odd thing was the css file that was being rewritten was being compressed (the styles.php file) but the styles.css file (the static one) was no longer being read by the browser. As soon as I deleted “.css” from that AddType line the browser started reading the file again and my css returned to normal, however it was no longer being compressed through apache.

Any thoughts on why a static css file is not being read by the browser if I add the type? I tried it with just text/css instead of .css and it was not compressing the file (but the browser interpreted it).

UPDATE:

I added this to the root htaccess file. We have compressed, interpretted sweetness now.

<filesMatch "\.css$">
FileETag None
<ifModule mod_headers.c>
Header set Content-type "text/css"
</ifModule>
</filesMatch>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:20:06+00:00Added an answer on June 1, 2026 at 7:20 pm

    When you run a CSS file through the PHP pre-processor, PHP will automatically output it as a text/html file, via default headers, since you’re not manually specifying it. So really, your browser is receiving a file with a .css extension which has headers claiming it’s an HTML file, so it’s trying to interpret it as HTML rather than CSS.

    If your CSS file actually needs to be run as PHP and there is PHP in it, you need to re-issue the appropriate file type so when it output, it’s still CSS:

    <?php
    header('Content-type: text/css');
    ?>
    

    You can’t just send a CSS file through PHP and expect it to work exactly the same. If you’re not actually pre-processing it with PHP, then you shouldn’t be sending it through there.


    As for the deflation issue, I could never actually get mod_deflate to work personally (no idea why). I had to use mod_gzip instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is one very interesting problem. I am using SQL Server 2008. I have
I have run into a very interesting problem trying to debug my custom PHP
I've come across a very interesting problem.. quite lost actually. Suppose I have a
I have came across very interesting problem which I think it's on Salesforce's end
I have a very interesting problem on my LinqToSql model. On some of my
I have a very interesting problem. I use this technologies in WPF app: Caliburn.Micro
Have come against an interesting problem and I'm stumped. Basically on one of our
I have an interesting/annoying problem with some VBScripts running on Windows 2003 Server (they
i have a very interesting problem. background i've used TTreeView for years but only
I have a very interesting problem. I have a table where I have data,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.