# Clean URLs with Camping and Apache

**URL:** <https://www.ruby-forum.com/t/clean-urls-with-camping-and-apache/83199>\
**Category:** Ruby\
**Created:** [January 24, 2007, 9:05am UTC](https://www.ruby-forum.com/t/clean-urls-with-camping-and-apache/83199 "2007-01-24T09:05:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@amra](https://www.ruby-forum.com/u/amra)\
**Post date:** [January 24, 2007, 9:05am UTC](https://www.ruby-forum.com/t/clean-urls-with-camping-and-apache/83199/1 "2007-01-24T09:05:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@amra](https://www.ruby-forum.com/u/amra)\
**Post date:** [January 24, 2007, 6:08pm UTC](https://www.ruby-forum.com/t/clean-urls-with-camping-and-apache/83199/2 "2007-01-24T18:08:51Z")

</div>

On Wed, Jan 24, 2007 at 05:05:05PM +0900, Max C. 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/FastCGI.html](http://camping.rubyforge.org/classes/Camping/FastCGI.html)
- 

[http://code.whytheluckystiff.net/camping/wiki/TheCampingServerForApache](http://code.whytheluckystiff.net/camping/wiki/TheCampingServerForApache)

\_why

---

<div class="post-metadata">

**Author:** ![amra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/3ec8ea/32.png) [@amra](https://www.ruby-forum.com/u/amra)\
**Post date:** [January 24, 2007, 7:46pm UTC](https://www.ruby-forum.com/t/clean-urls-with-camping-and-apache/83199/3 "2007-01-24T19:46:17Z")

</div>

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
