Guys,
I've got a Mojolicious app running under CGI, but my css and js files are not being served from the pubic directory. Here's my htaccess file:
AddHandler cgi-script .pl
Options +ExecCGI
IndexIgnore *
RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/public/%{REQUEST_URI} -f
RewriteRule ^(.*) public/$1 [L]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteRule ^(.*) script/
my_app.pl [L]
RewriteEngine on
# Rewrite only if the request isn't for a real file, directory, or symlink.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ script/
my_app.pl/$1 [L]
In MyApp.pm I have:
$self->hook( before_dispatch => sub {
my $self = shift;
$self->req->url->base(Mojo::URL->new(q{
http://my-servername/dir/my_app/}));
});
My URLs appear correctly in the page source as
/dir/my_app/css/file.css and /dir/my_app/js/file.js but clicking them in the source just displays the entire page content rather than the css/js. I'm not quite sure how to configure the rewrite correctly, can anyone help?
Thanks
MJ.