Browse files

Merge pull request #10045 from senny/document_relative_url_root

document how to deploy to a subdirectory [ci skip]
  • Loading branch information...
2 parents da49e9a + b76015b commit 90e743f0fae3089caed7dd2a348deb7c11e4bf38 @senny senny committed Aug 7, 2013
Showing with 39 additions and 2 deletions.
  1. +39 −2 guides/source/
@@ -301,7 +301,7 @@ The schema dumper adds one additional configuration option:
* `config.action_controller.allow_forgery_protection` enables or disables CSRF protection. By default this is `false` in test mode and `true` in all other modes.
-* `config.action_controller.relative_url_root` can be used to tell Rails that you are deploying to a subdirectory. The default is `ENV['RAILS_RELATIVE_URL_ROOT']`.
+* `config.action_controller.relative_url_root` can be used to tell Rails that you are [deploying to a subdirectory](configuring.html#deploy-to-a-subdirectory-relative-url-root). The default is `ENV['RAILS_RELATIVE_URL_ROOT']`.
* `config.action_controller.permit_all_parameters` sets all the parameters for mass assignment to be permitted by default. The default value is `false`.
@@ -535,14 +535,51 @@ Imagine you have a server which mirrors the production environment but is only u
That environment is no different than the default ones, start a server with `rails server -e staging`, a console with `rails console staging`, `Rails.env.staging?` works, etc.
+### Deploy to a subdirectory (relative url root)
+By default Rails expects that your application is running at the root
+(eg. `/`). This section explains how to run your application inside a directory.
+Let's assume we want to deploy our application to "/app1". Rails needs to know
+this directory to generate the appropriate routes:
+config.relative_url_root = "/app1"
+alternatively you can set the `RAILS_RELATIVE_URL_ROOT` environment
+Rails will now prepend "/app1" when generating links.
+#### Using Passenger
+Passenger makes it easiy to run your application in a subdirectory. You can find
+the relevant configuration in the
+[passenger manual](
+#### Using a Reverse Proxy
+#### Considerations when deploying to a subdirectory
+Deploying to a subdirectory in production has implications on various parts of
+* development environment:
+* testing environment:
+* serving static assets:
+* asset pipeline:
Rails Environment Settings
Some parts of Rails can also be configured externally by supplying environment variables. The following environment variables are recognized by various parts of Rails:
* `ENV["RAILS_ENV"]` defines the Rails environment (production, development, test, and so on) that Rails will run under.
-* `ENV["RAILS_RELATIVE_URL_ROOT"]` is used by the routing code to recognize URLs when you deploy your application to a subdirectory.
+* `ENV["RAILS_RELATIVE_URL_ROOT"]` is used by the routing code to recognize URLs when you [deploy your application to a subdirectory](configuring.html#deploy-to-a-subdirectory-relative-url-root).
* `ENV["RAILS_CACHE_ID"]` and `ENV["RAILS_APP_VERSION"]` are used to generate expanded cache keys in Rails' caching code. This allows you to have multiple separate caches from the same application.

0 comments on commit 90e743f

Please sign in to comment.