Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

rightpad/capistrano-simple-htaccess

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published