a bunch more to do with rewrites and headers and such
This commit is contained in:
parent
2c933b7837
commit
45b7062cc3
@ -127,10 +127,27 @@ module Apache
|
|||||||
self << "Include #{opts * " "}"
|
self << "Include #{opts * " "}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def apache_alias(*opts)
|
||||||
|
self << "Alias #{quoteize(*opts) * " "}"
|
||||||
|
end
|
||||||
|
|
||||||
def rotatelogs(path, time)
|
def rotatelogs(path, time)
|
||||||
"|#{@rotate_logs_path} #{path} #{time}"
|
"|#{@rotate_logs_path} #{path} #{time}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_header(hash)
|
||||||
|
hash.each do |key, value|
|
||||||
|
output = "Header set #{quoteize(key)}"
|
||||||
|
case value
|
||||||
|
when String
|
||||||
|
output += " #{quoteize(value)}"
|
||||||
|
when Array
|
||||||
|
output += " #{quoteize(value.first)} #{value.last}"
|
||||||
|
end
|
||||||
|
self << output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def writable?(path)
|
def writable?(path)
|
||||||
if !File.directory? File.split(path).first
|
if !File.directory? File.split(path).first
|
||||||
|
@ -13,6 +13,10 @@ module Apache
|
|||||||
def rewrites(&block)
|
def rewrites(&block)
|
||||||
self + indent(RewriteManager.build(&block))
|
self + indent(RewriteManager.build(&block))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def r301(*opt)
|
||||||
|
self << "Redirect permanent #{quoteize(*opt) * " "}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RewriteManager
|
class RewriteManager
|
||||||
@ -34,6 +38,13 @@ module Apache
|
|||||||
@rewrites << @rewrite
|
@rewrites << @rewrite
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def r301(*opts)
|
||||||
|
redirect = RedirectMatchPermanent.new
|
||||||
|
redirect.rule(*opts)
|
||||||
|
|
||||||
|
@rewrites << redirect
|
||||||
|
end
|
||||||
|
|
||||||
def rewrite_test(from, to, opts = {})
|
def rewrite_test(from, to, opts = {})
|
||||||
orig_from = from.dup
|
orig_from = from.dup
|
||||||
@rewrites.each do |r|
|
@rewrites.each do |r|
|
||||||
@ -48,7 +59,9 @@ module Apache
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class RewriteRule
|
class MatchableThing
|
||||||
|
def tag; raise 'Override this method'; end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@from = nil
|
@from = nil
|
||||||
@to = nil
|
@to = nil
|
||||||
@ -77,9 +90,17 @@ module Apache
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
output << "RewriteRule #{[@from.source, @to, @options].flatten * " "}"
|
output << "#{tag} #{[@from.source, @to, @options].flatten * " "}"
|
||||||
|
|
||||||
output * "\n"
|
output * "\n"
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class RewriteRule < MatchableThing
|
||||||
|
def tag; 'RewriteRule'; end
|
||||||
|
end
|
||||||
|
|
||||||
|
class RedirectMatchPermanent < MatchableThing
|
||||||
|
def tag; 'RedirectMatch permanent'; end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user