Skip to content

Instantly share code, notes, and snippets.

@bluestrike2
Created July 25, 2012 09:23
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 bluestrike2/3175261 to your computer and use it in GitHub Desktop.
Save bluestrike2/3175261 to your computer and use it in GitHub Desktop.
Statamic via pow.cx & rack-legacy
require 'rack-legacy'
require 'rack-rewrite'
use Rack::Rewrite do
send_file %r{([^\?]+)}, Dir.getwd + '$1', :if => Proc.new { |env|
path = File.expand_path(Dir.getwd + env['PATH_INFO'])
File.file?(path)
}
rewrite %r{([^\?]+)(\?(.*))?}, 'index.php/$1'
end
use Rack::Legacy::Php, 'public'
use Rack::Legacy::Cgi, 'public'
run Rack::File.new 'public'
gem 'rack-legacy'
gem 'rack-rewrite'
@bluestrike2
Copy link
Author

If you want to play with Statamic while enjoying the power of pow, the above should have you all set in no time flat.

@jonasd
Copy link

jonasd commented Jul 27, 2012

This is awesome, but the control panel (/admin) doesn't seem to work with the rewrite rule. Does it work on your install?

@bluestrike2
Copy link
Author

Actually, I realized that earlier today (well, yesterday). Got swamped with other work (d'oh!) and haven't had a chance to loop back around and figure it out. If I recall, it was an ENOTDIR so I'm assuming rack is looking for an admin.php directory and getting cranky when it doesn't find one, ignoring the php file itself. I'll need to double check.

At some point today when I'm not rushing to finish some work, I'll take a peek and see if I can't figure out a better solution. Sorry for getting your hopes up there!

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