Steve Piercy - Web Site Builder Virtual URLs without define_atbegin
Jan 20, 2010; 03:13
Steve Piercy - Web Site Builder
Virtual URLs without define_atbegin
The following is an alternative to using define_atbegin in a LassoStartup folder for virtual URLs on Apache 2.2. It works with Knop.
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.
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.
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 ----- [ var('siteroot')='/'; content_body = include($siteroot + 'index.lasso'); content_body -> trim; abort; ] ----- END /_urlhandler.lasso -----
--steve
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- Steve Piercy Web Site Builder Soquel, CA <web@StevePiercy.com> <http://www.StevePiercy.com/>
-- ############################################################# This message is sent to you because you are subscribed to the mailing list <knop@lists.montania.se>. To unsubscribe, E-mail to: <knop-off@lists.montania.se> Send administrative queries to <knop-request@lists.montania.se> List archive http://www.nabble.com/Knop-Framework-Discussion-f29076.html Project homepage http://montania.se/projects/knop/ Google Code has the latest downloads at http://code.google.com/p/knop/
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!