The following is an alternative to using define_atbegin in a LassoStartup folder for virtual URLs on Apache 2.2.
In this method because all virtual URLs get rewritten, response_filepath and response_path return the location of the URL handler, not the virtual URL. Therefore a custom tag to replace these tags is required.
Reference:
http://old.nabble.com/URL
Huge thanks to Bil Corry for his help and amazing skills.
----- BEGIN VIRTUAL HOST DIRECTIVES for APACHE 2.2 -----
<IfModule mod_rewrite.c>
# Turn mod_rewrite on.
RewriteEngine on
# Honor the server-wide rewrite rules if any exist.
RewriteOptions inherit
# Debug rewrite rules for use in development only.
# RewriteLogLevel can be 1-9.
# Configure the path to the rewrite log file.
# Do NOT enable in production or your log file will get huge quickly.
# RewriteLog /private/var/log/apache2/rewrite.log
# RewriteLogLevel 9
# Lasso gets all virtual files and directories
# that don't have an extension between 1 and 8 characters long
RewriteCond %{REQUEST_URI} !^.*\.[^.]{1,8}$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteRule (.*) /_urlhandler.lasso [L,NS,PT,E=X-VIRTUAL-PATH:$1]
RequestHeader unset X-VIRTUAL-PATH
RequestHeader set X-VIRTUAL-PATH %{X-VIRTUAL-PATH}e env=X-VIRTUAL-PATH
</IfModule>
----- END VIRTUAL HOST DIRECTIVES for APACHE 2.2 -----
----- BEGIN Custom Tag to replace response_filepath and response_path -----
[
// Overload response_filepath and response_path.
// Place in LassoStartup for the site.
define_tag('filepath',-namespace='response',-priority='high',-criteria=(params->size == 0));
local('vpath') = string;
protect;
#vpath = string_findregexp(client_headers,-find='(?im)^X-VIRTUAL-PATH:\\s*(.*)$')->get(2)->trim&;
/protect;
if(#vpath->size);
return(#vpath);
else;
return(response_filepath(-original));
/if;
/define_tag;
global('response_path') = tags_find('response_path');
define_tag('path',-namespace='response',-priority='replace');
local('vpath') = string;
local('vfilepath') = string;
protect;
#vpath = string_findregexp(client_headers,-find='(?im)^X-VIRTUAL-PATH:\\s*(.*)$')->get(2)->trim&;
#vfilepath = response_filepath->split('/')->last;
#vpath->removetrailing(#vfilepath);
/protect;
if(#vpath->size);
return(#vpath);
else;
return(global('response_path')->run);
/if;
/define_tag;
]
----- END Custom Tag to replace response_filepath and response_path -----
----- BEGIN /_urlhandler.lasso -----
[
// Optionally add logic to determine what gets processed by your framework.
content_body = include('/myframework.lasso');
content_body -> trim;
abort;
]
----- END /_urlhandler.lasso -----