Repository is archived
No commit activity in last 3 years
No release in over 3 years
Capistrano task for including a simple apache .htaccess file for redirects on deploy
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
>= 12.3.3
>= 1.2

Runtime

~> 3.14
 Project Readme

Capistrano::SimpleHtaccess

Gem Version

Capistrano task for including a simple apache .htaccess file for redirects on deploy.

Installation

Add this line to your application's Gemfile:

gem 'capistrano-simple-htaccess'

Then add it to your Capfile:

require 'capistrano/simple_htaccess'

And then:

$ bundle install

How it works

This gem hooks into Capistrano's flow by executing an upload task after the deploy:updated portion of Capistrano's flow. See the source for more details

The default .htaccess file

Found as a HEREDOC string in lib/capistrano/tasks/simple_htaccess.rake, but also here for your convenience:

<IfModule mod_rewrite.c>
  Options +FollowSymLinks

  RewriteEngine On
  RewriteBase "%<base>s"
  RewriteRule ^current(.*) %<base>s$1 [NC,R,END]
  RewriteRule ^((?!current/).*)$ current/$1 [NC,END]
</IfModule>

The %<base>s template strings are replaced with the value of your :deploy_to directory, with the :document_root variable removed from the string's prefix. This creates a base directory string.

Ex:

set :deploy_to, '/var/www/html/example1/public'
set :document_root, '/var/www/html'

# %<base>s would then be replaced with: /example1/public

Configuration

If you want a different .htaccess uploaded, just change the :HTACCESS variable as part of your deploy config. Ex:

set :HTACCESS, <<HTACCESS
# Put your .htaccess config here
HTACCESS

Contributing

Bug reports and pull requests are welcome!

License

The gem is available as open source under the terms of the MIT License.