[Dancer-users] URL rewrite, comments?

Joel Roth joelz at pobox.com
Thu Dec 2 08:38:37 CET 2010


Hi all,

Here is an update on a newbie dancing pilgrim's progress,
through the shoals of mod_rewrite.

Starting with the rewrite rules in Dancer::Deployment, I've
been trying to get the behavior I want from my website URLs.
I've got a solution (below) that allows access control using
.htaccess.  In future I expect to handle everything through
Dancer. 

I guess I'd like some feedback, how to do it better.
For example, I think RewriteBase might be a more concise 
way to introduce dispatch.cgi... if I could only get it right. 

Thanks for any thoughts on this.

Joel

# BEGIN htaccess
#
# dispatch.cgi launches dancer app

RewriteEngine On

# Dancer gets null path requests
# example.org   -> example.org/dispatch.cgi
# example.org/  -> example.org/dispatch.cgi

RewriteRule  ^.{0,1}$ dispatch.cgi [L]

# Pass existing file or directory links to apache
# example.org/audio
# example.org/audio/test.mp3

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .* - [L]

# Dancer gets everything else

RewriteRule (.+) dispatch.cgi/$1

# END htaccess



-- 
Joel Roth


More information about the Dancer-users mailing list