M
M
maolo2015-07-31 19:44:53
htaccess
maolo, 2015-07-31 19:44:53

Checking for the existence of a gzip file and setting up htaccess?

Tell me how to configure the return of gzip files through .htaccess, if it exists?
Those. do not reap the server, but check for the presence of a gzip file, and if it exists, then give it away (without the .gz extension, but with the title that it is a compressed file), if there is no gzip file, then give the uncompressed version of the file, for example, there is 3 files:

style.css
style.css.gz
style.ie.css

...
<link rel="stylesheet" href="css/style.css"/>
<link rel="stylesheet" href="css/style.ie.css"/>
...

style.css is given compressed (the .gz extension is removed from style.css.gz, respectively), and style.ie.css is given as is.
Is it possible to do this via .htaccess?
update: Accordingly, this is necessary for different types of files, in particular, for *.js, *.html, *.css

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zooks, 2015-08-02
@zooks

You don't need to upload files in .gz format, everything works on the fly.

<IfModule mod_gzip.c>
    mod_gzip_on         Yes
    mod_gzip_dechunk    Yes
    mod_gzip_item_include file		\.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include mime		^text\.*
    mod_gzip_item_include mime		^application/x-javascript.*
    mod_gzip_item_exclude mime		^image\.*
    mod_gzip_item_exclude rspheader	^Content-Encoding:.*gzip.*
</IfModule>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question