Rails, LSAPI, Rewrites, Contexts, Authentication

#1
I have a Rails LSAPI serving multiple virtual hosts (so the LSAPI is at the server level). Each virtual host operates off a single template, which has this for the template-wide rewrite rules:

RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/stylesheets*
RewriteCond %{REQUEST_FILENAME} !/images*
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^(.*)$ /system/maintenance.html [L]

RewriteRule ^/$ /index.html [QSA]
RewriteRule ^/([^.]+)$ /$1.html [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ /dispatch.lsapi [QSA,L]

This rewrite set has been the standard I've used for all Rails LSAPI hosts, but none of those hosts needed authentication on a subdirectory within the Rails application. I cannot see a way to convert these rewrite rules into contexts so that I can follow the same advice given in the post "Install/Configuration > authorization realm in rails context".

If there is a way to replace the last two rewrite groups, then I can see how it is possible using the correct priority for each rule. I need to, just like the other post, restrict /admin/ to an authentication realm, but I'm all at sea on how to inject this context before the last rewrite rule. Presently, adding a /admin Static Context does nothing because the URL has already been rewritten to /dispatch.lsapi by the time Contexts are run. And there is an admin directory, but requests are still rewritten to the LSAPI.

Any suggestions would be much appreciated. Thanks.
 
Top