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

  • SEARCH
  • Home
  • 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 4096458
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:02:56+00:00 2026-05-20T20:02:56+00:00

How could I create a simple content handler for apache .gz gzip content. I

  • 0

How could I create a simple content handler for apache .gz gzip content. I want it to uncompress say http://localhost/doc/FAQ/Linux-FAQ.gz and send it to the browser as plain text. There is a lot of documentation for Linux in /usr/share/doc and localhost/doc/. I don’t want to use zless, zcat or vim to read the content. I use apache to browse the documentation on my local machine and have my web browser revive it as standard text so that it does not ask me to download the *.gz file every time.

Alias /doc/ "/usr/share/doc/"
Alias local.doc "/usr/share/doc/"
<Directory "/usr/share/doc/">
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

But Now I want all those .gz file under /usr/share/doc/ to be servered as plain text. I think I could do that very simply with a python script in cgi-bin. I am looking for a nice content handler for those files. Like the way it php files are handled .gz should be uncompressed and sent to the browser.

<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml .php3
  AddType application/x-httpd-php-source .phps
</IfModule>
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

I see there is a mod_deflate, how would this apply. Could this handle the gzip content.

It would make browsing documentation so much easier. Any programing resources to help here would be nice.

  • 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-05-20T20:02:57+00:00Added an answer on May 20, 2026 at 8:02 pm

    I’ve used something like this before for js/css files (I modified the below to match your needs). Add this to your virtualhost entry:

    Alias /doc/ "/usr/share/doc/"
    Alias local.doc "/usr/share/doc/"
    <Directory /usr/share/doc>
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    
        AddEncoding gzip gz
        <FilesMatch "\.gz$">
          ForceType text/plain
          Header set Content-Encoding: gzip
        </FilesMatch>
    </Directory>
    

    Updated above to match your code

    In ubuntu ensure that Headers module is enabled

    $ sudo a2enmod headers  
    $ sudo a2enmod deflate
    $ sudo apache2ctl restart
    

    Update2: Realized that “AddEncoding gzip gz” was missing.. otherwise, file kept trying to download.

    Update3: Added apache module deflate install command. Here’s my deflate.conf:

    <IfModule mod_deflate.c>
          # these are known to be safe with MSIE 6
          AddOutputFilterByType DEFLATE text/html text/plain text/xml
    
          # everything else may cause problems with MSIE 6
          AddOutputFilterByType DEFLATE text/css
          AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
          AddOutputFilterByType DEFLATE application/rss+xml
    </IfModule>
    

    You could first try with some other type of file (e.g. a css file). Example:

    cd /usr/share/doc
    cat ".styles { width: 50px; }" > test.css
    gzip -c test.css > test.css.gz
    

    Add this to your virtualhost:

        <FilesMatch "\.css\.gz$">
            ForceType text/css
            Header set Content-Encoding: gzip
        </FilesMatch>
    

    Test http://127.0.0.1/doc/test.css and http://127.0.0.1/doc/test.css.gz and see what result you get.

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

Sidebar

Related Questions

Let's say that I have a Flash website where you could create an avatar
Obviously I could create a Calendar object with the date and use get(DAY) on
I remember back when I used to do C++ Builder apps, you could create
Years ago when I was working with C# I could easily create a temporary
We get the following error; The request was aborted: Could not create SSL/TLS secure
I know I could write scripts and create jobs to run them, but at
Could anyone could point me to some code/give me ideas on how to create
I could not find any pointers on how to create a menubar icon on
How could I find out if a URL is available and usable to create
I'm using WebForms MVP to create some simple reporting applications. Most of these applications

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.