Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I do a minor upgrade of the core, my custom .htaccess and robots.txt are overwritten.

How do I prevent that?

share|improve this question
up vote 4 down vote accepted

You can build a site totally with git to help manage this process. The process is basically

Git clone into your DOCROOT:

git clone --branch 7.x http://git.drupal.org/project/drupal.git /var/www/mysite/docroot

Rename the remote:

git remote rename origin drupal

Checkout the latest tag, and make a site branch for your site

git checkout 7.26
git branch -b mysite

Now, you can build your site and customize robots.txt and .htaccess to your needs.

When there is a core update, you can

git fetch drupal

and then use the normal git methods for merging your changes in, eg

git merge 7.27

or you can preview what will happen, check for conflicts, etc.

If you do this, you need to make sire you don't do a plain

drush pm-update drupal

as this will then mess things up. I do not think that drush pm-update --lock=drupal works to prevent this.

share|improve this answer
    
While this works, IMO it is a crazy work around. It is very likely that the op will drush pm-update drupal. – Sonicthoughts Sep 20 '15 at 17:03
    
@Sonicthoughts The OP wanted a way to preserve minor updates to core. This solves it. A drush pm-update drupal would nuke any patches that the user has made to core. Unfortunately, there are some long outstanding issues to core that have patches that have not been committed (eg, the ones for Secure Pages to work properly). – MPD Sep 20 '15 at 17:10

One way to solve this, is as follows:

  1. Create a set of patches that patches any altered files (i.e. .htaccess, robots.txt, and other files where you're have added customization).
  2. After downloading the new minor release of the core, apply the patches. Check if there are any conflicts.
  3. If there are no conflicts, great - you're done! If there are conflicts, resolve them. Iterate until there are no more conflicts.

You can script this, using drush for doing the upgrade and git for managing patches and checking for conflicts. This usually makes upgrading quick and painless, even if you've have customized .htaccess, robots.txt, and other files.

share|improve this answer
    
I don't see the reason for the downvote here. I use this method on sites that I don't fully manage with git. – MPD Mar 28 '14 at 13:53

For Apache & configurations without Git, you can alias the root robots.txt to another file. For example, in httpd.conf:

<VirtualHost *:80>
    ServerName mydevsite.example.com
    DocumentRoot /var/www/html/mydevsite
    Alias /robots.txt /var/www/html/mydevsite/robots.disallowed.txt
</VirtualHost>

robots.txt will still be overwritten with each core update, but will be unused by visitors & crawlers.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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