Question

I guess you all know the LoadModule directive form mod_so. I want to do the opposite, unload module for specific directory via .htaccess file. Does UnloadModule exist?

I want to reach highest script compatibility by *disabling all modules except mod_rewrite*, because unwanted modules are messing with my script in some way. Is there an easy way?

Side question: How to disable mod_deflate only? It is the biggest badass. I want to handle compression internally in my scripts.

Was it helpful?

Solution

1. I think it is not possible to unload already loaded module. That's all what I can say on #1.

2. Let's put this code in .htaccess:

<IfModule deflate_module>
    # Insert filter
    SetOutputFilter DEFLATE
    # Don't compress images
    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

    <IfModule headers_module>
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</IfModule>

This will compress .html files (as long s it is big enough, of course).

Now, let's add html to the list of excluded extensions:

    SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|html)$ no-gzip dont-vary

Now reload the same html file in browser (make sure browser actually loads it fresh (should be 200 response) and not from cache or via 304 Not Modified response). It now sends html file with no compression at all. Firebug confirms: only 480 bytes when compressed and 11.6 KB of uncomressed data (the html file is basically a single paragraph of text repeated 20 or so times, hence the very good compression).

I'm sure you can modify it to your needs very easily (on my server compression is not enabled globally -- that is the code I use when I need it -- so I cannot provide 100% exact code for you, unfortunately). For example:

SetEnvIfNoCase Request_URI .+$ no-gzip dont-vary

OTHER TIPS

You can prevent a module from being loaded in the first place by simply not having a LoadModule directive for the module in question in your configuration at all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top