【问题标题】:Getting folder application runs from in Mojolicious Lite获取文件夹应用程序从 Mojolicious Lite 运行
【发布时间】:2014-05-26 16:52:01
【问题描述】:

我希望能够从根目录 (www.domain.com/) 或子文件夹 (www.domain.com/misc/mymojoapp/) 在共享主机上运行我的 Mojolicious Lite 应用程序。 应用程序的 .pl 文件始终位于域 (www.domain.com/cgi-bin/myapp.pl) 的 cgi-bin 文件夹中,我想使用 .htaccess 中的 mod_rewrite 规则指向应用程序。图片/css/js 文件将在www.domain.com/misc/mymojoapp/support 下。

但我无法弄清楚如何可靠地获取路径的misc/mymojoapp/ 部分,以便将其传递到模板中。有什么办法吗?

【问题讨论】:

    标签: perl mojolicious-lite


    【解决方案1】:
    # set apache handler to treat your specified script name(s) as a CGI program
    Options +ExecCGI
    <Files ~ "(mymojoapp)$">
      SetHandler cgi-script
    </Files>
    # rewrite any requests into the appRewriteEngine onRewriteCond %{REQUEST_FILENAME} 
    !-fRewriteRule ^(.*)$ misc/mymojoapp/$1 [L]
    

    在你的应用中

    # set env variable to use root for pretty URLs
    
    $ENV{SCRIPT_NAME} = '/';
    

    为漂亮的 URL 更改上述设置

    【讨论】:

    猜你喜欢
    • 2015-10-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-12
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 1970-01-01
    相关资源
    最近更新 更多