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&language=en&theme=olivero&include=eJx9jkkOwyAMRS8E4UwG3MYKwZFtQnP7DiosuujG-oO_9BJXw4c1KCFLO6AsaSa-UN3UpX8vxlwiiONCJwqHG2KepsJJdzDi6hVfowxyzfLgjoLZx8vHwmmbhSJIWn0FEe6_aaeMTlcWS80Gz_BOLzXcQwRF9yULg7Apyhi89UIvInUnYdfwucvOuRV8AnZza-g" />
<script src="/sites/default/files/js/js_nm7oZaj2aF8XaIi-p7eaT2-i2XqwfUniyb8I2Ul6JtY.js?scope=header&delta=0&language=en&theme=olivero&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
Comments
Comment #2
cilefen commentedI have 10.4.0 sites working on Apache so there must be additional steps to reproduce the bug. Perhaps it is related to the Apache configuration that is in the Docker image. What is that configuration?
Comment #3
tchandelle commentedSomehow, it's not letting me update the issue. So here is the Dockerfile and instructions on how to build it, that I use for my tests, hope it helps. It's a standard Apache configuration.
https://gitlab.com/-/snippets/4789476
Comment #4
quietone commentedChanges are made on on 11.x (our main development branch) first, and are then back ported as needed according to the Core change policies.
Comment #5
bernd31 commentedHello,
I had the same problem and found that yes, it's the Apache configuration.
mod_rewrite must be enabled, then the aggregation works.
I found that mentioned here: https://www.drupal.org/project/drupal/issues/3381293#comment-16111995
With that knowledge, more sources can be found, like
https://www.drupal.org/project/drupal/issues/3365639
or
https://www.drupal.org/docs/getting-started/system-requirements/web-serv...
Comment #6
smustgrave commentedThe .htaccess being present seems correct. Is there a contrib module being used?