AnswerBun.com

Composer updates .htaccess file when updating

Drupal Answers Asked by albertski on February 11, 2021

I am using composer with Drupal lightning. If I update Drupal via composer, it updates the .htaccess file.

Is there any way to prevent the .htaccess file from being overwritten?

3 Answers

One way to append your changes at end of .htaccess file once its been updated by scaffold.

htaccess-custom-changes.txt contains your custom changes require to add.

"drupal-scaffold": {
  "file-mapping": {
    "[web-root]/.htaccess": {
      "append": "patches/htaccess-custom-changes.txt"
     }
}

Answered by Ashish Vitthal Dalvi on February 11, 2021

While the accepted answer is correct and this prevent the .htacces file from being overwritten, most updates done to that files are linked to security issues. You should patch the file instead, as described in this answer : https://drupal.stackexchange.com/a/271147/25673

Here's a copy of the answer by Stef Van Looveren

In the scripts section of your composer.json file, use the following:

"post-drupal-scaffold-cmd": [
  "patch -p0 < patches/htaccess.patch"
]

(this requires "drupal-composer/drupal-scaffold" in your require section)

Answered by Arakwar on February 11, 2021

 "extra": {
   "drupal-scaffold": { 
       "source": "http://cgit.drupalcode.org/drupal/plain/{path}?h={version}", 
       "excludes": [ ".htaccess", "robots.txt" ]
       }
}

Put this above code in your composer.json file.

Answered by harsh_behl_0007 on February 11, 2021

Add your own answers!

Related Questions

KernelEvents::REQUEST is not fired on cached pages

2  Asked on December 8, 2021 by user34185

     

Add column to custom field schema

3  Asked on December 8, 2021 by coder1

 

Order receipt email content

1  Asked on December 8, 2021 by pete-l

 

Date time save in database

0  Asked on December 8, 2021 by pratip-ghosh

   

How can I create a recommended project in the root directory?

2  Asked on December 6, 2021 by user2574948

   

Wrapping fields together in a Views Exposed Filter

1  Asked on December 4, 2021 by typologist

   

Submit form and disable submission button

7  Asked on December 4, 2021 by matt9292

   

How to check if an entity is referenced before deleting?

2  Asked on December 2, 2021 by halofx

   

Add class to {{ link }} twig attribute

3  Asked on December 2, 2021

   

Remove field attributes using hook_form_alter()

1  Asked on November 30, 2021 by senthilkumar

 

How to send email to submitter in a webform?

2  Asked on November 30, 2021 by cel57

     

Ask a Question

Get help from others!

© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP