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?
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
2 Asked on December 8, 2021 by user34185
1 Asked on December 8, 2021 by bohus-ulrych
2 Asked on December 6, 2021 by user2574948
1 Asked on December 4, 2021 by user13777
1 Asked on December 4, 2021
1 Asked on December 4, 2021
2 Asked on December 2, 2021 by halofx
1 Asked on December 2, 2021 by tbj
2 Asked on November 30, 2021 by surendra-prasad
2 Asked on November 30, 2021 by cel57
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP