[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Clean URLs with Camping and Apache

Max Cantor

1/24/2007 8:00:00 AM

I've set Camping up to run with FastCGI, MySQL and Apache. I've set
some RewriteRule directives in an .htaccess file to enable clean URLs
with the app, that is:

/dev/my_app/foo/0

becomes...

/dev/my_app/dispatch.fcgi?foo/0

However, as soon as this URL hits Camping, the clean URLs stop because
Camping generates all of its links using the
/dev/my_app/dispatch.fcgi?foo/0 approach instead of /dev/my_app/foo/0.
Is there a good way to coax this behavior out of Camping?

Thanks,

Max

2 Answers

_why

1/24/2007 5:08:00 PM

0

On Wed, Jan 24, 2007 at 05:05:05PM +0900, Max Cantor wrote:
> Is there a good way to coax this behavior out of Camping?

Camping doesn't work like Rails, so you shouldn't have to use
RewriteRule to force the URLs.

AddHandler fastcgi-script fcgi
ScriptAlias / /usr/local/www/data/dispatch.fcgi/

If you're mounting on a subdirectory `my_app`:

ScriptAlias /my_app /usr/local/www/data/dispatch.fcgi/

The dispatch.rb is like:

#!/usr/bin/env ruby
require 'rubygems'
require 'camping/fastcgi'
require 'my_app'
Camping::Models::Base.establish_connection :adapter => 'sqlite3',
:database => "/tmp/camping.db"
Camping::FastCGI.start(MyApp)

See also:

* http://camping.rubyforge.org/classes/Camping/Fa...
* http://code.whytheluckystiff.net/camping/wiki/TheCampingServe...

_why

Max Cantor

1/24/2007 6:41:00 PM

0

Thanks _why! I got it working. However... this is all well and good
if we have access to the server/v-host config, but what if we're on a
shared host and only have .htaccess overrides (albeit very thorough
ones)? If there is a /cgi-bin already defined, then some symlink
voodoo could work, but what if there's no ScriptAlias directive
whatsoever?

Thanks again.

Max

On Jan 24, 10:08 am, _why <w...@ruby-lang.org> wrote:
> On Wed, Jan 24, 2007 at 05:05:05PM +0900, Max Cantor wrote:
> > Is there a good way to coax this behavior out of Camping?
> Camping doesn't work like Rails, so you shouldn't have to use
> RewriteRule to force the URLs.
>
> AddHandler fastcgi-script fcgi
> ScriptAlias / /usr/local/www/data/dispatch.fcgi/
>
> If you're mounting on a subdirectory `my_app`:
>
> ScriptAlias /my_app /usr/local/www/data/dispatch.fcgi/
>
> The dispatch.rb is like:
>
> #!/usr/bin/env ruby
> require 'rubygems'
> require 'camping/fastcgi'
> require 'my_app'
> Camping::Models::Base.establish_connection :adapter => 'sqlite3',
> :database => "/tmp/camping.db"
> Camping::FastCGI.start(MyApp)
>
> See also:
>
> *http://camping.rubyforge.org/classes/Camping/Fa...
> *http://code.whytheluckystiff.net/camping/wiki/TheCampingServe...
>
> _why