I need to patch .htaccess file which is located in project's root (docroot in this case), my project is written using composer and I created a patch using git, added it to the /patches directory and wrote a composer.json entry:

"drupal/drupal": [
            "title": "htaccess patch",
            "url": "docroot/profiles/laeg/patches/redirects.patch"

Sadly after running composer update my patch doesn't appear in the patches list therefore it is not applied. I was told that I should patch drupal/drupal but it seems to not be a case, has some done anything like this and could suggest me something? Project is running Drupal 7.


For drupal 8, use the following. In the 'scripts' section of your composer.json, add

"post-drupal-scaffold-cmd": [
  "patch -p0 < patches/htaccess.patch"
  • I had to use -p1 instead of -p0 for it to work for me. Jan 13 '21 at 19:12

A little late, but check out https://github.com/drupal-composer/drupal-scaffold/issues/45. They give a few solutions for handling the issue.

  • Welcome to Drupal Answers! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – mpdonadio
    May 16 '18 at 23:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.