Commit 32a44de4 authored by Terence Lee's avatar Terence Lee

custom redirects

parent 6fe82621
......@@ -20,6 +20,7 @@ class NginxConfig
json["clean_urls"] ||= false
json["routes"] ||= {}
json["routes"] = Hash[json["routes"].map { |route, target| [to_regex(route), target] }]
json["redirects"] ||= {}
json.each do |key, value|
self.class.send(:define_method, key) { value }
end
......
......@@ -42,6 +42,12 @@ http {
}
<% end %>
<% redirects.each do |path, hash| %>
location <%= path %> {
return <%= hash['status'] || 301 %> <%= hash['url'] %>;
}
<% end %>
<% routes.each do |route, path| %>
location ~ ^<%= route %>$ {
alias <%= root %>/<%= path %>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment