augustash / capistrano-ash

August Ash recipes for Capistrano
http://augustash.com
MIT License
73 stars 12 forks source link

DRUPAL - htaccess on production deploy #21

Closed americkson closed 11 years ago

americkson commented 12 years ago

For productions sites we need to have a solution to specify if a site should be forced to the 'www' sub-domain or with the 'non-www' option. In the default Drupal htaccess file there are a couple lines that simply need to be un-commented to allow for the 'www' or 'non-www' redirect.

grafikchaos commented 11 years ago

Closing this issue because it can easily be handled by creating staging or production versions of the htaccess file with any environment specific changes you need and committing the to the repository.

By default we'll look for the htaccess files named in the following formats and in this order:

  1. htaccess.<ENV>.dist ( i.e., htaccess.production.dist )
  2. htaccess.<ENV> ( i.e., htaccess.production )
  3. htaccess.dist

You can see the default ash:htaccess task here and the relevant code snippet is below

namespace :ash do
  desc 'Copy distribution htaccess file'
  task :htaccess, :roles => :web do
    case true
    when remote_file_exists?("#{latest_release}/htaccess.#{stage}.dist")
      run "mv #{latest_release}/htaccess.#{stage}.dist #{latest_release}/.htaccess"
    when remote_file_exists?("#{latest_release}/htaccess.#{stage}")
      run "mv #{latest_release}/htaccess.#{stage} #{latest_release}/.htaccess"
    when remote_file_exists?("#{latest_release}/htaccess.dist")
      run "mv #{latest_release}/htaccess.dist #{latest_release}/.htaccess"
    else
      logger.important "Failed to move the .htaccess file in #{latest_release} because an unknown pattern was used"
    end
  end
end