j.burbidge

Registered
Apr 27, 2020
4
0
1
UK
cPanel Access Level
Root Administrator
I have a server that's not comprssing the output for any of the sites.
I've been though many suggestion in this forum, but nothing seems to work.
We do have another server with the same version of WHM & it is working on there & as far as I can see, the configuration is the same.

mod_deflate is installed in EasyApache 4
zlib.output_compression is anebled in the MultiPHP INI Editor for the php version being used (PHP7.3)
"Compress All Content" is selected in the cPanel for the sites
The .htaccess file has the following:
Code:
<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 handler ^cgi-script$
    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>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/x-font
    AddOutputFilterByType DEFLATE application/x-font-truetype
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/x-font-otf
    AddOutputFilterByType DEFLATE application/x-font-opentype
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/opentype
    # For Olders Browsers Which Can't Handle Compression
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
In the php.ini for each site, there is a line for:
zlib.output_compression On


Does anyone know where I can check next?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,496
1,009
313
cPanel Access Level
Root Administrator
Hey there! Since you have already compared the settings to another WHM system, it might be best to open a ticket with our team so we can check this directly on the server. If you do that, please post the ticket number here so I can follow along and keep the community updated with our findings.
 

j.burbidge

Registered
Apr 27, 2020
4
0
1
UK
cPanel Access Level
Root Administrator
Hi there

I've narrowed this down even further... it's definately NOT the CMS.

As mentioned on the ticket, I've setup a new account on the server & have uploaded a file & set the .htaccess to compress.
This is working & the output is compressed as expected on https://www.mysite.com/test1.php.

For reference, the .htaccess file is:
Code:
<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 handler ^cgi-script$
    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>
I've then setup a sub-folder & uploaded a file - when accessed directly (e.g. https://www.mysite.com/public/test2.php) this file is compressed as expected.

In my .htaccess file, i've added the following at the top...
Code:
<IfModule mod_rewrite.c>
    Options +FollowSymlinks
    RewriteEngine On

    # Rewrite to 'public' folder
    RewriteCond %{HTTP_HOST} ^www.mysite.com$
    RewriteCond %{REQUEST_URI} !public/
    RewriteRule (.*) public/$1 [L]
</IfModule>
This is to redirect all traffic to the sub-folder - so the URL of the page is now https://www.mysite.com/test2.php
The page is being served as expected, but it's not compressed!

However, if I access it directly (using https://www.mysite.com/public/test2.php) it IS compressed.

So, something is preventing the compression when the RewriteRule is used.
I've tried simple things like re-ordering the .htaccess file & changing the folder name, but nothing seems to work.

As mentioned at the start, I have another server running the same WHM/cPanel & have replicated this on that box & it all works as expected.

Thanks for your suggestions!