• Resolved Oliver Campion

    (@domainsupport)


    Hello,

    Following your instructions to add support for .css.gz and .js.gz by adding the following lines to .htaccess …

    
    #Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
    
    #Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
    
    #Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=is_gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1]
    Header set Content-Encoding "gzip" env=is_gzip
    

    This results in pages not being served at all with the following error …

    500 Internal Server Error
    
    Internal Server Error
    
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    
    Please contact the server administrator at admin@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
    
    More information about this error may be available in the server error log.
    
    Apache/2.4.41 (Ubuntu) Server Port 443

    Please advise.

    Oliver

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author launchinteractive

    (@launchinteractive)

    Hi Oliver, Do you have mod_deflate and mod_rewrite enabled?

    Thread Starter Oliver Campion

    (@domainsupport)

    I believe so …

    ssh@localhost:~# apachectl -M
    Loaded Modules:
     core_module (static)
     so_module (static)
     watchdog_module (static)
     http_module (static)
     log_config_module (static)
     logio_module (static)
     version_module (static)
     unixd_module (static)
     access_compat_module (shared)
     actions_module (shared)
     alias_module (shared)
     auth_basic_module (shared)
     authn_core_module (shared)
     authn_file_module (shared)
     authz_core_module (shared)
     authz_host_module (shared)
     authz_user_module (shared)
     autoindex_module (shared)
     deflate_module (shared)
     dir_module (shared)
     env_module (shared)
     filter_module (shared)
     mime_module (shared)
     mpm_prefork_module (shared)
     negotiation_module (shared)
     proxy_module (shared)
     proxy_fcgi_module (shared)
     reqtimeout_module (shared)
     rewrite_module (shared)
     setenvif_module (shared)
     socache_shmcb_module (shared)
     ssl_module (shared)
     status_module (shared)
    Plugin Author launchinteractive

    (@launchinteractive)

    ok, I’m not exactly sure. I don’t get any errors when I use it. I’m testing it on a standard WHM/cPanel setup.

    Are there any more details in the apache logs?

    You could try css or js on its own and see if either work. That might help identify the problem.

    Thread Starter Oliver Campion

    (@domainsupport)

    Good shout. The issue was we didn’t have a2enmod headers enabled. Might be worth updating readme.txt to ensure users know to have those three mods enabled for Gzip.

    The page now loads but inspecting the sources, looks like the regular .css and .js files are being served? Tested in Chrome and Safari. Would you mind confirming? https://williamstewart.me

    I’ve looked on the server and the corresponding .css.gz and .js.gz files all exist within /wp-content/mmr/

    Plugin Author launchinteractive

    (@launchinteractive)

    Great. I will update the readme.

    Those rewrites are meant to serve the gzipped version of the css or js and the url stays the same so it should be working. If you need to double check you can modify the generated css but not the gz version.. then you should be able to determine that the correct files is being served.

    Thread Starter Oliver Campion

    (@domainsupport)

    OK, it’s working. Thank you.

    Looks like the browser automatically gunzips the .gz file.

    Thank you.

    Oliver

    Thread Starter Oliver Campion

    (@domainsupport)

    Hello again, we have modified your .htaccess rules as follows which will prevent errors if the headers aren’t enabled …

    # BEGIN Serve gzip compressed CSS and JS files
    <IfModule mod_rewrite.c>
    	<IfModule mod_deflate.c>
    		<IfModule mod_headers.c>
    #Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
    #Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
    #Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1,E=is_gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1]
    Header set Content-Encoding "gzip" env=is_gzip
    		</IfModule>
    	</IfModule>
    </IfModule>
    # END Serve gzip compressed CSS and JS files

    Feel free to include this in your readme.txt ??

    Oliver

    Plugin Author launchinteractive

    (@launchinteractive)

    Nice. I’ve added that in.

    Thread Starter Oliver Campion

    (@domainsupport)

    We’ve added support in Deny All Firewall so if you use that plugin and the firewall is enabled then .htaccess rules will be added.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Gzip setup results in 500 Internal Server Error’ is closed to new replies.