From 1b7dc469b3217a1662235bc030cb4932e3b266d5 Mon Sep 17 00:00:00 2001 From: mathdesc Date: Sat, 18 Aug 2012 14:27:32 -0400 Subject: [PATCH] Added a comment: For lighttpd with mod_magnet --- ..._aa03c337b31d7acb95761eb51caab1ef._comment | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 doc/forum/missing_pages_redirected_to_search-SOLVED/comment_1_aa03c337b31d7acb95761eb51caab1ef._comment diff --git a/doc/forum/missing_pages_redirected_to_search-SOLVED/comment_1_aa03c337b31d7acb95761eb51caab1ef._comment b/doc/forum/missing_pages_redirected_to_search-SOLVED/comment_1_aa03c337b31d7acb95761eb51caab1ef._comment new file mode 100644 index 000000000..eac5dc165 --- /dev/null +++ b/doc/forum/missing_pages_redirected_to_search-SOLVED/comment_1_aa03c337b31d7acb95761eb51caab1ef._comment @@ -0,0 +1,44 @@ +[[!comment format=mdwn + username="mathdesc" + subject="For lighttpd with mod_magnet" + date="2012-08-18T18:27:32Z" + content=""" +Same can be done for lighttpd via a lua script (said rewrite.lua) using *mod_magnet* than need to be installed and +called in your conf like this : + +
+# error-handler for status 404                                         
+$HTTP[\"url\"] =~ \"^/mysite/\" { 
+magnet.attract-physical-path-to = ( server.document-root + \"/rewrite.lua\" )
+}
+
+ +Ref : +[[mod_magnet docs|http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModMagnet]] + + + +
+
+  function removePrefix(str, prefix)    
+        return str:sub(1,#prefix+1) == prefix..\"/\" and str:sub(#prefix+2)
+  end
+
+
+
+   attr = lighty.stat(lighty.env[\"physical.path\"])
+   local prefix = '/mysite'
+   if (not attr) then
+        -- we couldn't stat() the file 
+        -- let's generate a xapian query with it
+        new_uri =removePrefix(lighty.env[\"uri.path\"], prefix)
+        print (\"page not found : \" .. new_uri .. \" asking xapian\")
+        lighty.env[\"uri.path\"] = \"/mysite/ikiwiki.cgi\"    
+        lighty.env[\"uri.query\"] = \"P=\" .. new_uri  
+        lighty.env[\"physical.rel-path\"] = lighty.env[\"uri.path\"]
+        lighty.env[\"physical.path\"] = lighty.env[\"physical.doc-root\"] .. lighty.env[\"physical.rel-path\"]
+    end
+
+ +Hope this is useful to you :) +"""]] -- 2.26.2