htaccess file prevents the generation of aggregated assets

Created on 3 January 2025, 19 days ago

Problem/Motivation

.htaccess file in sites/default/files prevents the generation of aggregated assets.

When the Aggregate CSS files and Aggregate JavaScript files are activated, the HTML file contains these headers

<link rel="stylesheet" media="all" href="/sites/default/files/css/css_YbF3Y8xDeYp8pvuqmQTGuJUJi9r25E3sOQ-qy3fGH28.css?delta=1&amp;language=en&amp;theme=olivero&amp;include=eJx9jkkOwyAMRS8E4UwG3MYKwZFtQnP7DiosuujG-oO_9BJXw4c1KCFLO6AsaSa-UN3UpX8vxlwiiONCJwqHG2KepsJJdzDi6hVfowxyzfLgjoLZx8vHwmmbhSJIWn0FEe6_aaeMTlcWS80Gz_BOLzXcQwRF9yULg7Apyhi89UIvInUnYdfwucvOuRV8AnZza-g" />

<script src="/sites/default/files/js/js_nm7oZaj2aF8XaIi-p7eaT2-i2XqwfUniyb8I2Ul6JtY.js?scope=header&amp;delta=0&amp;language=en&amp;theme=olivero&amp;include=eJx9i0sOgCAMBS-EcAZPYgo02lgpKfg5vsZgTFy4e58ZT-OQKaPzLZggqeJRV2AXdc3A9l06pjSXf6SKsAe9IMXnhlBpw9s2wldUcQVBw9TtFNE0xz3up1ssATL2caF0AiccRRw"></script>

But these returns 404 errors. No files are being generated in sites/default/files/css/ and sites/default/files/js/.

Unless the .htaccess is deleted. In this case, the generation works, files are correctly generated in these directories and returns to the client.

But the .htaccess kept being regenerated.

Tested on Drupal 10.4.x, 10.5.x, 11.0.x and 11.1x, running on the docker image php:8.3-apache (Apache/2.4.62 (Debian)).
Also tested Drupal 10.3.10, running on an OVH Perso Host, PHP 8.1.29 , Apache 2.4

Steps to reproduce

1. Install a new Drupal site (tested with "Standard" and "Demo: Umami Food Magazine (Experimental)") on Apache
2. The CSS is not showing correctly
3. Delete the file sites/default/files/.htaccess
4. Refresh the page. The CSS is showing correctly
5. Visit the Admin Configuration page (/admin/config). The .htaccess file is recreated
6. Clear the cache (/admin/config/development/performance). The CSS is not generated anymore

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Postponed: needs info

Version

11.1 🔥

Component

asset library system

Created by

🇧🇪Belgium tchandelle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024