2
votes

I am running the Perl Dancer framework following the instructions written in Dancer::Deployment for running as a cgi-script. This allows me to display a default page for the '/' route, but I can't seem to do anything beyond that. For example, let's say that I want to request something like http://localhost/myroute and have that handled by the '/myroute' route handler. How would I pull this off?

I am using apache's mod_rewrite to direct my requests. Currently, if I try the above, I end up with a message like "The requested URL /cgi-bin/dancer.cgimyroute was not found on this server." Below is the contents of my .htaccess.

<IfModule mod_rewrite.c>    
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ /cgi-bin/dancer.cgi$1 [QSA,L]
</IfModule>

I am running Apache 2.2 on Windows XP with Dancer 1.3030. I understand why I am getting the error message that I am getting. What I am looking for is some sample code for handling the "/myroute" route and perhaps some suggestions regarding any modifications that I should make to my .htaccess file.

1
I'd guess that you need dancer.cgi/$1Quentin
Wow! That seems obvious now, but it's actually the answer.Scott
Probably worth submitting that as an answer rather than a comment so it can be accepted?David Precious

1 Answers

2
votes

The configuration needed a / after dancer.cgi:

<IfModule mod_rewrite.c>    
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ /cgi-bin/dancer.cgi/$1 [QSA,L]
</IfModule>

Thanks to Quentin above.