0

I want to be able to run my Mojolicious Lite app on shared hosting either from root (www.domain.com/) or subfolder (www.domain.com/misc/mymojoapp/). The app's .pl file always goes to cgi-bin folder of the domain (www.domain.com/cgi-bin/myapp.pl) and I want to use mod_rewrite rules in .htaccess to point to the app. Images/css/js files would be under www.domain.com/misc/mymojoapp/support.

But I cannot figure out how I reliably get misc/mymojoapp/ part of the path so I can pass it into templates. Is there a way?

flamey
  • 2,311
  • 4
  • 33
  • 40

1 Answers1

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]

and in your App

# set env variable to use root for pretty URLs

$ENV{SCRIPT_NAME} = '/';

Change the above setting for pretty URL

Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
  • I cannot change server settings on shared hosting - is `Options +ExecCGI` set in htaccess? I do have that re-write rule in my `.htaccess`, and I tried `$ENV{SCRIPT_NAME} = '/';` - that did not change anything. – flamey May 26 '14 at 08:58
  • Check this: https://github.com/kraih/mojo/wiki/Dreamhost and this https://groups.google.com/forum/#!topic/mojolicious/bxdlP-MKuIQ – Chankey Pathak May 26 '14 at 09:00
  • Yes add the first part in `.htaccess` – Chankey Pathak May 26 '14 at 09:05