htaccess preventing site to access aggregated css and js

Created on 4 February 2020, over 5 years ago
Updated 23 October 2024, 7 months ago

Hello,

I have a drupal 8 site being deployed to live server.
I installed Advanced CSS/JS Aggregation to minified and combine css & js into one file. When css & js is aggregated, a new css file is created in
"sites/default/files/css/css_hXUAq2PGK9p4je0X4bXRmI0PGqgBcVwcHZqKVLddhEk.css?q564dg". When I make changes to css file, I flush all caches in drupal, a new version of aggregated css file will be regenerated inside sites/default/files/css. However, I found that whenever I flush all caches, .htaccess inside sites/default/files is updated automatically.

Original .htaccess:

# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

Updated .htaccess:

##### below lines were added into .htaccess #####
# Deny all requests from Apache 2.4+.
<IfModule mod_authz_core.c>
 Require all denied
</IfModule>

# Deny all requests from Apache 2.0-2.2.
<IfModule !mod_authz_core.c>
 Deny from all
</IfModule>
########################################

# Turn off all options we don't need.
Options -Indexes -ExecCGI -Includes -MultiViews

# Set the catch-all handler to prevent scripts from being executed.
SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
<Files *>
  # Override the handler again if we're run later in the evaluation list.
  SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003
</Files>

# If we know how to do it safely, disable the PHP engine entirely.
<IfModule mod_php5.c>
  php_flag engine off
</IfModule>

when the extra lines were added, all the files in /sites/default/files are not accessible.
Other than that, I also installed `Asset Injector` to inject custom css and js into pages. Not sure if this module cause the issue.

I couldn't find any related issue from google.
Does anyone have any idea about this issue?

🐛 Bug report
Status

Postponed: needs info

Version

11.0 🔥

Component

file system

Created by

🇲🇾Malaysia johny5360

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.

  • 🇳🇿New Zealand quietone

    Anyone know if this problem exists on a currently supported version of Drupal?

    Since we need confirmation that this is still a problem, I am setting the status to Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

    Thanks!

  • Status changed to Closed: cannot reproduce 2 months ago
  • 🇦🇺Australia acbramley

    Closing as per #10

Production build 0.71.5 2024