Problemas con CSS y JS rotos en Joomla usando OpenLiteSpeed (Hostinger, CyberPanel)


Si tu sitio Joomla se ve sin estilos o los archivos Javscript no funcionan correctamente al usar OpenLiteSpeed por mala codificación, probablemente se deba a una doble compresión de archivos CSS y JS. Esto ocurre porque OpenLiteSpeed ya aplica compresión gzip o Brotli a nivel de servidor, y si además tienes activa la compresión en el archivo .htaccess
, los archivos se comprimen dos veces y el navegador no puede interpretarlos correctamente.
¿Cómo solucionarlo?
La solución es muy sencilla: comenta la sección de GZIP & BROTLI en tu archivo .htaccess
. Solo tienes que buscar la sección correspondiente y anteponer #
a cada línea, por ejemplo:
## GZIP & BROTLI
## These directives are only enabled if the Apache mod_headers module is enabled.
## This section will check if a .gz file exists and if so will stream it
## directly or fallback to gzip any asset on the fly
## If your site starts to look strange after enabling this file, and you see
## ERR_CONTENT_DECODING_FAILED in your browser console network tab,
## then your server is already gzipping css and js files and you don't need this
## block enabled in your .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 compression.
# RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1,E=no-brotli:1]
# RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1,E=no-brotli:1]
#
# <FilesMatch "(\.js\.gz|\.css\.gz)$">
# # Serve correct encoding type.
# Header set Content-Encoding gzip
#
# # Force proxies to cache gzipped &
# # non-gzipped css/js files separately.
# Header append Vary Accept-Encoding gzip
#
# # Force proxies to cache gzipped &
# # non-gzipped css/js files separately.
# Header append Vary Accept-Encoding
# </FilesMatch>
#</IfModule>
Importante: Después de guardar los cambios, recuerda reiniciar OpenLiteSpeed para que el nuevo .htaccess
tenga efecto: Manage Services -> Services Status -> OpenLiteSpeed -> Restart!
Resumen
- Si ves tu sitio sin estilos o sin JS, revisa la compresión.
- Comenta la sección de GZIP & BROTLI en
.htaccess
. - Reinicia OpenLiteSpeed.
¡Listo! Así evitarás problemas de archivos CSS
Si además usas Cloudflare como proxy, limpia la cache: Caching -> Configuration -> Purge Everything -> Purge Everything