Skip to content

Instantly share code, notes, and snippets.

@minikomi
Created April 18, 2011 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minikomi/924979 to your computer and use it in GitHub Desktop.
Save minikomi/924979 to your computer and use it in GitHub Desktop.
Redirection for unfound assets to dropbox for padrino
error 404 do
link = "http://dl.dropbox.com/u/#{dropboxid}/#{public_folder}"+request.path_info
uri = URI.parse(link)
response = nil
Net::HTTP.start(uri.host, uri.port) { |http|
response = http.head(uri.path.size > 0 ? uri.path : "/")}
if response.code == "200"
redirect link
else
redirect '/' #any place you like, can be 404 page.
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment