As per tecjam's comment, it is not possible.
Although not strictly a solution, you could make a copy of the .htaccess file outside of the magento installation directory.
When you want to update via composer you can check the .htaccess file's history on Magento's github for any changes, to ensure that you aren't missing crucial alterations to the file.
Then, once you have applied any updates to the version of the .htaccess
file you copied outside of the magento directory, you can copy the file, or create a symlink, back into the magento installation folder.
Without utilising some additional package management software, this is probably the cleanest solution.
Although it may only prove useful when Magento updates are scheduled automatically, if you wish to use the .htaccess file you copied outside of the magento installation directory irrespective of any changes that may be made to the original, then you could create a cronjob by running crontab -e
and specifying:
0 0 1 * * /usr/bin/rsync -a /path/to/file/outside/magento/directory/.htaccess /path/to/magento/directory/.htaccess
This example would replace the .htaccess
file within the Magento installation directory at 12am on the 1st day of each month.
magento2-base
package composer.json. If changes occur there, you want your file to be updated. By excluding it you'd have to apply any changes manually anyway after each update ..magento-deploy-ignore
configuration incomposer.json
: stackoverflow.com/a/51961956/2534880