Module: Apache::Rewrites
- Included in:
- Config
- Defined in:
- lib/apache/rewrites.rb
Overview
Handle the creation of RewriteRules, RewriteConds, Redirects, and RedirectMatches
Instance Method Summary collapse
-
#enable_rewrite_engine(options = {}) ⇒ Object
Enable the rewrite engine, optionally setting the logging level.
-
#r301(*opt) ⇒ Object
Create a permanent Redirect.
- #rewrite(*opt, &block) ⇒ Object
-
#rewrites(*opt, &block) ⇒ Object
Pass the block to RewriteManager.build.
Instance Method Details
#enable_rewrite_engine(options = {}) ⇒ Object
Enable the rewrite engine, optionally setting the logging level
enable_rewrite_engine :log_level => 1 #=>
RewriteEngine on
RewriteLogLevel 1
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apache/rewrites.rb', line 11 def enable_rewrite_engine( = {}) blank_line! rewrite_engine! :on .each do |option, value| case option when :log_level rewrite_log_level! value end end blank_line! end |
#r301(*opt) ⇒ Object
Create a permanent Redirect
r301 '/here', '/there' #=> Redirect permanent "/here" "/there"
36 37 38 39 40 41 42 43 |
# File 'lib/apache/rewrites.rb', line 36 def r301(*opt) if first = opt.first if !first.kind_of?(::String) raise "First parameter should be a String. Did you mean to wrap this in a rewrites block? #{first}" end end self << "Redirect permanent #{opt.quoteize * " "}" end |
#rewrite(*opt, &block) ⇒ Object
29 30 31 |
# File 'lib/apache/rewrites.rb', line 29 def rewrite(*opt, &block) raise "You probably want rewrites #{opt.quoteize * " "} do" if block end |
#rewrites(*opt, &block) ⇒ Object
Pass the block to RewriteManager.build
24 25 26 27 |
# File 'lib/apache/rewrites.rb', line 24 def rewrites(*opt, &block) self + indent(RewriteManager.build(*opt, &block)) self << '' end |