作为 CGI 脚本运行时如何处理 Dancer 路线?
我正在按照 Dancer::Deployment 中编写的说明运行 Perl Dancer 框架,以作为 cgi 脚本运行。这允许我显示“/”路由的默认页面,但除此之外我似乎无法做任何事情。例如,假设我想请求类似 http://localhost/myroute 的内容,并由 '/ 处理myroute' 路由处理程序。我该如何完成这个任务呢?
我正在使用 apache 的 mod_rewrite 来引导我的请求。目前,如果我尝试上述操作,我最终会收到一条消息,例如“在此服务器上找不到请求的 URL /cgi-bin/dancer.cgimyroute”。以下是我的 .htaccess 的内容。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/dancer.cgi$1 [QSA,L]
</IfModule>
我在 Windows XP 上运行 Apache 2.2 和 Dancer 1.3030。我明白为什么我会收到这样的错误消息。我正在寻找的是一些用于处理“/myroute”路由的示例代码,也许还有一些关于我应该对 .htaccess 文件进行的任何修改的建议。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
配置需要在
dancer.cgi
之后有一个/
:感谢上面的 Quentin。
The configuration needed a
/
afterdancer.cgi
:Thanks to Quentin above.