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 * " "}"
|
||||
end
|
||||
|
||||
def apache_alias(*opts)
|
||||
self << "Alias #{quoteize(*opts) * " "}"
|
||||
end
|
||||
|
||||
def rotatelogs(path, time)
|
||||
"|#{@rotate_logs_path} #{path} #{time}"
|
||||
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
|
||||
def writable?(path)
|
||||
if !File.directory? File.split(path).first
|
||||
|
@ -13,6 +13,10 @@ module Apache
|
||||
def rewrites(&block)
|
||||
self + indent(RewriteManager.build(&block))
|
||||
end
|
||||
|
||||
def r301(*opt)
|
||||
self << "Redirect permanent #{quoteize(*opt) * " "}"
|
||||
end
|
||||
end
|
||||
|
||||
class RewriteManager
|
||||
@ -34,6 +38,13 @@ module Apache
|
||||
@rewrites << @rewrite
|
||||
end
|
||||
|
||||
def r301(*opts)
|
||||
redirect = RedirectMatchPermanent.new
|
||||
redirect.rule(*opts)
|
||||
|
||||
@rewrites << redirect
|
||||
end
|
||||
|
||||
def rewrite_test(from, to, opts = {})
|
||||
orig_from = from.dup
|
||||
@rewrites.each do |r|
|
||||
@ -48,7 +59,9 @@ module Apache
|
||||
end
|
||||
end
|
||||
|
||||
class RewriteRule
|
||||
class MatchableThing
|
||||
def tag; raise 'Override this method'; end
|
||||
|
||||
def initialize
|
||||
@from = nil
|
||||
@to = nil
|
||||
@ -77,9 +90,17 @@ module Apache
|
||||
|
||||
end
|
||||
|
||||
output << "RewriteRule #{[@from.source, @to, @options].flatten * " "}"
|
||||
output << "#{tag} #{[@from.source, @to, @options].flatten * " "}"
|
||||
|
||||
output * "\n"
|
||||
end
|
||||
end
|
||||
|
||||
class RewriteRule < MatchableThing
|
||||
def tag; 'RewriteRule'; end
|
||||
end
|
||||
|
||||
class RedirectMatchPermanent < MatchableThing
|
||||
def tag; 'RedirectMatch permanent'; end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user