Skip to content

Instantly share code, notes, and snippets.

@paulcook
Created February 21, 2012 21:44
Show Gist options
  • Save paulcook/1879178 to your computer and use it in GitHub Desktop.
Save paulcook/1879178 to your computer and use it in GitHub Desktop.
Legacy PHP with POW
require 'rubygems'
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
INDEXES = ['index.html','index.php', 'index.cgi']
use Rack::Rewrite do
rewrite %r{(.*/$)}, lambda {|match, rack_env|
to_return = rack_env['PATH_INFO']
INDEXES.each do |index|
if File.exists?(File.join(Dir.getwd, rack_env['PATH_INFO'], index))
to_return = rack_env['PATH_INFO'] + index
end
end
to_return
}
end
use Rack::Legacy::Php, Dir.getwd
use Rack::Legacy::Cgi, Dir.getwd
run Rack::File.new Dir.getwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment