I have a web interface that i need to maintain and improve, written in a plain old CGI.pm way. That app is not using templating system neither. It's served by apache, like that:
/var/www/vhost/myapp/cgi-bin/app.cgi
/htdocs/css/styles.css
/htdocs/js/script.js
To add new pages to that app, and make my life easyer, i want to host a Dancer or Dancer2 app next to it, i was thinking about something like that:
/var/www/vhost/myapp/cgi-bin/app.cgi
/cgi-bin/dispatch.cgi (the one from Dancer2)
/htdocs/css/styles.css
/js/script.js
/dancer_public/...
/dancer2/lib/...
/views/...
/environement/...
In the dispatcher, i'm changing the path to reach the Dancer2 bin/app.psgi. I added the following .htaccess file to the htdocs dir:
# BEGIN dancer application htaccess
RewriteEngine On
RewriteBase /v2
RewriteRule ^/v2$ /cgi-bin/dispatch.cgi [L]
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule v2/(.*) /cgi-bin/dispatch.cgi/$1 [L]
# END dancer application htaccess
By doing that,
Now that you have the setup, here is where i have an issue, the redirection from v2 to the dancer app is working really well, however, in order to keep consistent, i would like to have the uri_for creating url from v2 , but it's using the SCRIPT_NAME as base url, to show the issue, when i'm creating that url: uri_for('/mypage'),
i would like to have that url : example.com/v2/mypage,
but instead i have url example.com/cgi-bin/dispatch.cgi/mypage
SCRIPT_NAME environment variable is containing cgi-bin/dispatch.cgi , i have one terrible hack, that is working, but clearly not the solution, i can have my expected behavior by forcing SCRIPT_NAME to /v2 in the cgi dispatcher, in a BEGIN block. If someone as a clean solution for that, that would be of a great help!
Thanks
Have the same problem with D1.
$ENV{SCRIPT_NAME} = '';
inside dispatch.fcgi helps me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.