Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 error when compressing files with .htaccess

I'm trying to compress files with .htaccess but I'm getting a 500 internal error,

This is the code I'm trying to use.

# JavaScript compression htaccess ruleset
AddHandler application/x-httpd-php .js
php_value auto_prepend_file gzip-js.php
php_flag zlib.output_compression On

I've also tried this but getting the same error,

<files *.html>
SetOutputFilter DEFLATE
</files>

Any suggestions why?

like image 859
believe me Avatar asked Aug 29 '12 16:08

believe me


Video Answer


2 Answers

Do you have mod_deflate installed? Try this instead and see if your error goes away.

<ifModule mod_deflate.c>
<Files *.html>
SetOutputFilter DEFLATE
</Files>
</ifModule>

If this resolves the 500 error, then you probably don't have mod_deflate installed. You can test it by visiting HTTP Compression Test.

If you have access, you may be able to enable it by uncommenting the following lines in your httpd.conf file.

LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so

Then you will need to add an output type for each file type you wish to compress.

AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

As mentioned in the comments, AddOutputFilterByType depends on mod_filter. If you still get a 500 error you should check that this module is loaded too.

You can read more here: Use mod_deflate to Compress Web Content delivered by Apache

I can't find any documentation that suggests whether Siteground supports mod_deflate or not. Their KB suggests using gZip from PHP.

How to enable gZIP compression for your pages?
How to compress my CSS with gZIP?

like image 68
Nilpo Avatar answered Oct 09 '22 11:10

Nilpo


After spending hours of search I found this article, thought someone else might find it helpful,

Enjoy.

like image 42
believe me Avatar answered Oct 09 '22 11:10

believe me