Skip to content

Instantly share code, notes, and snippets.

@mjc
Forked from ngs/config.ru
Last active January 3, 2016 06:09
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 mjc/8420610 to your computer and use it in GitHub Desktop.
Save mjc/8420610 to your computer and use it in GitHub Desktop.
config.ru for running CakePHP apps under Pow. Includes an app/webroot rewrite and some other things from the rack-legacy example.
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
webroot = File.join(Dir.getwd,'app','webroot')
use Rack::Rewrite do
rewrite %r{/(.*)}, lambda { |match, rack_env|
File.exists?(File.join(webroot,match[1])) ? File.join('app','webroot',match[1]) : '/app/webroot/index.php/%s' % match[1]
}
rewrite '/', 'index.php'
end if File.exists?(webroot)
use Rack::ShowExceptions
use Rack::Legacy::Index
use Rack::Legacy::Php, Dir.getwd
use Rack::Static, :urls => %w{/css /files /img /js /favicon.ico}, :root => webroot
run Rack::File.new Dir.getwd
@superirale
Copy link

Hice nice one, but which directory should i save this config file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment