I am using Perl Dancer2 for my project. On my local development environment everything works fine, but on my production server it generates all the links with the dispatch.cgi script in the links.
<link rel="stylesheet" href="<% request.base %>/css/style.css">
creates
<link rel="stylesheet" href="http://dance.mydomain.tld/dispatch.cgi/css/style.css">
Same with an image link in embedded CSS:
background: url(http://dance.mydomain.tld/dispatch.cgi/images/random2k22/filename_2022_a4_960x347.png) top center no-repeat;
When I use the example Rewrite code for Apache httpdocs mentioned on the official Dancer2::Manual::Deployment, the site doesn't work at all as it hops in a redirection loop.
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
AddHandler cgi-script .cgi
# Apache 2.2
Order allow,deny
Allow from all
# Apache 2.4
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /dispatch.cgi$1 [QSA,L]
When I use the following it at least loads. But it takes quite long for the image to load (via the dispatcher?):
RewriteCond %{ENV:REDIRECT_STATUS} 200 [OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ - [L]
RewriteRule ^(.*)$ /dispatch.cgi$1 [QSA,L]
It's so frustrating.
What am I not understanding and/or doing wrong here?