<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>nordisch by nature - Home</title>
  <id>tag:nordisch.org,2008:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://nordisch.org/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://nordisch.org/" rel="alternate" type="text/html"/>
  <updated>2007-04-26T23:33:01Z</updated>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2007-04-26:79</id>
    <published>2007-04-26T23:28:00Z</published>
    <updated>2007-04-26T23:33:01Z</updated>
    <category term="lighttpd"/>
    <category term="1.5.x"/>
    <category term="lighttpd"/>
    <link href="http://nordisch.org/2007/4/26/running-1-5-x-eat-your-own-dog-food" rel="alternate" type="text/html"/>
    <title>running 1.5.x - eat your own dog food</title>
<content type="html">
            &lt;p&gt;now we are running on 1.5.x r1820. :D&lt;/p&gt;
&lt;p&gt;
As i want to deploy 1.5 on some more important host pretty soon, i migrated my own host to it.
Now my fastcgi apps are handled with &lt;a href=&quot;http://smarden.sunsite.dk/runit&quot;&gt;runit&lt;/a&gt; and lighty only gets the sockets configured. I will do a longer article about runit and fastcgi in the next days.
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2007-04-13:77</id>
    <published>2007-04-13T17:56:00Z</published>
    <updated>2007-04-13T18:26:22Z</updated>
    <category term="lighttpd"/>
    <category term="1.4.14"/>
    <category term="lighttpd"/>
    <category term="releases"/>
    <link href="http://nordisch.org/2007/4/13/it-s-done-we-have-1-4-14" rel="alternate" type="text/html"/>
    <title>it's done. we have 1.4.14</title>
<content type="html">
            Yes! My first release is done. &lt;a href=&quot;http://www.lighttpd.net/2007/4/13/lighttpd-1-4-14-released&quot;&gt;1.4.14&lt;/a&gt; can now be downloaded at www.lighttpd.net. It is mainly a bug fix release, but it has 2 important security fixes for you. :)
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2007-04-10:71</id>
    <published>2007-04-10T13:24:00Z</published>
    <updated>2007-04-10T13:29:33Z</updated>
    <category term="lighttpd"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2007/4/10/hah-it-s-not-only-me" rel="alternate" type="text/html"/>
    <title>Hah! it's not only me!:)</title>
<content type="html">
            &lt;p&gt;Yes I am advocating to use &lt;a href=&quot;http://trac.lighttpd.net/trac/wiki/Docs:ModMagnet&quot;&gt;mod_magnet&lt;/a&gt; a lot. So many people might think, i am the only one really using it. But you are wrong. Today &lt;a href=&quot;http://jan.kneschke.de/&quot;&gt;Jan&lt;/a&gt; found another nice article about mod_magnet and how it can save your life. :)&lt;/p&gt;
&lt;p&gt;The folks at sitepoint posted a nice article how to save load time for CSS and JS files. For more see &lt;a href=&quot;http://www.sitepoint.com/blogs/2007/04/10/faster-page-loads-bundle-your-css-and-javascript/&quot;&gt;http://www.sitepoint.com/blogs/2007/04/10/faster-page-loads-bundle-your-css-and-javascript/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I wonder if they will put the script in public. Let's ask them... so stay tuned. :D&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2007-02-26:20</id>
    <published>2007-02-26T23:25:00Z</published>
    <updated>2007-02-26T23:59:34Z</updated>
    <category term="lighttpd"/>
    <category term="drupal"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2007/2/26/you-learn-something-new-every-day-today-lua-patterns" rel="alternate" type="text/html"/>
    <title>you learn something new every day - today lua patterns</title>
<content type="html">
            &lt;p&gt;
Ok, you could have thought that &quot;/drupal-5.1&quot; might cause trouble. Sadly it does. The &quot;-&quot; is a special char for lua patterns. (for more see &lt;a href=&quot;http://www.lua.org/manual/5.1/manual.html#5.4.1&quot;&gt;chapter 5.4.1 of the lua docs&lt;/a&gt;)
&lt;/p&gt;
&lt;p&gt;
So i visited my friends at #lua on freenode. After a few minutes of discussion with &lt;a href=&quot;http://lua-users.org/wiki/RiciLake&quot;&gt;rici&lt;/a&gt; and prec, we got a new &lt;a href=&quot;/drupal.lua&quot;&gt;drupal.lua&lt;/a&gt;. It no longer uses patterns but a simple substring function. And now we happily work with &quot;/drupal-5.1&quot; aswell.
&lt;/p&gt;
&lt;h2&gt;The details&lt;/h2&gt;

&lt;p&gt;Why did it fail in first place?&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;
-- prefix without the trailing slash
local prefix = &quot;/drupal-5.1&quot;
&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;and later we did:&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;request_uri = string.gsub(lighty.env[&quot;uri.path&quot;], prefix .. &quot;/(.+)&quot;, &quot;%1&quot;)
&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;
We pass an unescaped string to the pattern match. Especially the &quot;-&quot; was causing trouble here. Of course there would have been the option to quote all the special chars properly with &quot;%&quot;. But thats more work than what is really needed. Rici and prec suggest do add a &lt;code&gt;removePrefix&lt;/code&gt; function based on string.sub
&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;
function removePrefix(str, prefix)
  return str:sub(1,#prefix+1) == prefix..&quot;/&quot; and str:sub(#prefix+2)
end
-- calculate the relevant part of the request_uri
request_uri = removePrefix(lighty.env[&quot;uri.path&quot;], prefix)
&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;Last but not least rici suggest a small optimization to the query string construction. From the old ugly ...&lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;
-- make sure the request_uri is not empty.
if (string.gmatch(request_uri, &quot;.+&quot;)) then
  if lighty.env[&quot;uri.query&quot;] then
      lighty.env[&quot;uri.query&quot;] = lighty.env[&quot;uri.query&quot;] .. &quot;&amp;q=&quot; .. request_uri
  else
      lighty.env[&quot;uri.query&quot;] = &quot;q=&quot; .. request_uri
  end
end
&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;... we come to the new and shiny ... &lt;/p&gt;
&lt;code&gt;
&lt;pre&gt;
local uriquery = lighty.env[&quot;uri.query&quot;] or &quot;&quot;
lighty.env[&quot;uri.query&quot;] = uriquery .. (uriquery ~= &quot;&quot; and &quot;&amp;&quot; or &quot;&quot;) .. &quot;q=&quot; .. request_uri
&lt;/pre&gt;
&lt;/code&gt;
&lt;p&gt;You learn something new every day.
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2007-02-06:19</id>
    <published>2007-02-06T20:55:00Z</published>
    <updated>2007-03-04T06:30:34Z</updated>
    <category term="lighttpd"/>
    <category term="clean url"/>
    <category term="drupal"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2007/2/6/drupal-on-lighttpd-with-clean-urls" rel="alternate" type="text/html"/>
    <title>Drupal on lighttpd with clean urls (updated)</title>
<content type="html">
            &lt;p&gt;
  Many people have asked for an example for
  &lt;a href=&quot;http://trac.lighttpd.net/trac/wiki/Docs:ModMagnet&quot;&gt;mod_magnet&lt;/a&gt;
  that doesnt involve &lt;a href=&quot;http://www.rubyonrails.org&quot;&gt;Ruby on Rails&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  I have choosen drupal. &lt;a href=&quot;http://drupal.org./&quot;&gt;Drupal&lt;/a&gt; is a nice
  little content managment platform written in php. I used it before
  switching to rails. :) Though lets start.
&lt;/p&gt;
&lt;p&gt;
  As already mentioned in the &lt;a href=&quot;http://pixel.global-banlist.de/2006/10/6/dr-magneto-vs-mr-404-handler&quot;&gt;&quot;Dr. Magneto vs Mr 404 handler&quot;&lt;/a&gt;
  article, drupal uses a small nice rewrite rule set:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Ok. &lt;a href=&quot;http://www.lighttpd.net/&quot;&gt;Lighttpd&lt;/a&gt; doesnt support -d/-f.
  So let&#8217;s use mod_magnet. For the example we assume drupal is already
  installed and accessible under &quot;http://www.example.org/drupal/&quot;.
  The needed &lt;a href=&quot;/drupal.lua&quot;&gt;drupal.lua&lt;/a&gt; can be downloaded
  &lt;a href=&quot;/drupal.lua&quot;&gt;here&lt;/a&gt;. The script is nearly as simple as
  the rails example. So is the integration with lighttpd. The configsnippet is:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$HTTP[&quot;url&quot;] =~ &quot;^/drupal&quot; {
    # we only need index.php here.
    index-file.names = ( &quot;index.php&quot; )
    # for clean urls
    magnet.attract-physical-path-to = ( &quot;/etc/lighttpd/drupal.lua&quot; )
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
Last but not least you need to configure drupal to use clean urls. You go to &quot;Admin&quot; =&amp;gt; &quot;Site configuration&quot; =&amp;gt; &quot;Clean urls&quot; (quick link http://www.example.org/drupal/index.php?q=admin/settings/clean-urls ) and click on the &quot;Run the clean URL test&quot; link. If it was successful you can enable clean urls and save the settings.
&lt;/p&gt;
&lt;h3&gt;
  &quot;But my drupal runs under &#8216;/someotherpath&#8217;,
  what do i need to change?&quot;
&lt;/h3&gt;
&lt;p&gt;
  Of course the url conditional in the config snippet above. You also need to
  change the prefix in the drupal.lua. &lt;strong&gt;Do not&lt;/strong&gt; append a
  trailing slash there.
&lt;/p&gt;
&lt;h2&gt;Alternatives?&lt;/h2&gt;
&lt;h3&gt;404 handler?&lt;/h3&gt;
&lt;p&gt;
  Of course it would work as well, but the 404 handler breaks the 403 return
  code, which is used by drupal.
&lt;/p&gt;
&lt;h3&gt;url.rewrite-once?&lt;/h3&gt;
&lt;p&gt;
  This is a possible solution aswell. But you need to rewrite all static
  files to itself.
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;url.rewrite-once = (
    &quot;^(/drupal/files.*)&quot;       =&gt; &quot;$1&quot;,
    &quot;^(/drupal/themes.*)&quot;      =&gt; &quot;$1&quot;,
    &quot;^/drupal/([^.?]*)\?(.*)$&quot; =&gt; &quot;/drupal/index.php?q=$1&amp;$2&quot;,
    &quot;^/drupal/([^.?]*)$&quot;       =&gt; &quot;/drupal/index.php?q=$1&quot;,
)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  Killes mentioned another rewrite solution on
  &lt;a href=&quot;irc://irc.freenode.org/drupal&quot;&gt;#drupal on freenode&lt;/a&gt;:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;url.rewrite-once = (
    &quot;^/drupal/system/test/(.*)$&quot; =&gt; &quot;/drupal/index.php?q=system/test/$1&quot;,
    &quot;^/drupal/([^.?]*)\?(.*)$&quot;   =&gt; &quot;/drupal/index.php?q=$1&amp;$2&quot;,
    &quot;^/drupal/([^.?]*)$&quot;         =&gt; &quot;/drupal/index.php?q=$1&quot;,
    &quot;^/drupal/search/node/(.*)$&quot; =&gt; &quot;/drupal/index.php?q=search/node/$1&quot;
)&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Security&lt;/h2&gt;
&lt;p&gt;
  A small side note, in SA-2006-006 the drupal team warned about a security
  hole through carefully named arbitrary scripts in the files directory.
  The apache workaround of course doesnt work here either. The following
  block should secure your server with lighttpd. :)
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# &quot;Fix&quot; for Drupal SA-2006-006, requires lighttpd 1.4.13
$HTTP[&quot;url&quot;] =~ &quot;^/drupal/files&quot; {
    cgi.assign = ()
    fastcgi.server = ()
    scgi.server = ()
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
  For versions before 1.4.13 you need to move your cgi/fastcgi/scgi
  defintions into a conditional that inverts the match as shown in
  the example above. But i have to admit it complicates the config
  quite a bit. ;)
&lt;/p&gt;
&lt;p&gt;
Update: the script was broken for prefices containing lua patterns special chars. This has been &lt;a href=&quot;/2007/2/26/you-learn-something-new-every-day-today-lua-patterns&quot;&gt;fixed&lt;/a&gt; and a new version was uploaded.
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2007-02-04:18</id>
    <published>2007-02-04T23:59:00Z</published>
    <updated>2007-02-06T22:25:23Z</updated>
    <category term="lighttpd"/>
    <category term="cleanurl"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2007/2/4/how-to-use-cleanurl-lua" rel="alternate" type="text/html"/>
    <title>how to use cleanurl.lua?</title>
<content type="html">
            This is actually a good question. And Jan just reminds me that i never explained that. So here we go:

First of all you need a mod_magnet, obviously. =)
As second step you need to add mod_magnet to the server.modules array. Make sure mod_magnet is loaded before mod_fastcgi/mod_scgi/mod_cgi/mod_proxy/mod_proxy_core(1.5.x-snapshots).

Last but not least you can add this line to your lighttpd.conf:
&lt;pre&gt;
magnet.attract-physical-path-to = ( &quot;/etc/lighttpd/cleanurl-v5.lua&quot; )
&lt;/pre&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2006-12-23:17</id>
    <published>2006-12-23T20:59:00Z</published>
    <updated>2007-02-06T22:26:00Z</updated>
    <category term="lighttpd"/>
    <category term="lighttpd"/>
    <category term="mod_uploadprogress"/>
    <link href="http://nordisch.org/2006/12/23/waiting-for-mod_uploadprogress" rel="alternate" type="text/html"/>
    <title>waiting for mod_uploadprogress</title>
<content type="html">
            &lt;p&gt;Seriously ... i do not understand why everyone cries for this. I can understand the point of showing some progressbar for long running uploads.&lt;/p&gt;

&lt;p&gt;But... the browser already has all needed informations. it knows the original size. it knows how much data was sent already. We could do the whole calculation fully client side. Now what are we doing? We waste a 2nd connection to poll the webserver &quot;how much data did i send to you already?&quot;. This feels stupid to me.&lt;/p&gt;

&lt;p&gt;I am going to file bugs against Opera and Firefox to allow reading the needed informations from javascript.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2006-10-14:16</id>
    <published>2006-10-14T21:04:00Z</published>
    <updated>2007-02-06T22:41:14Z</updated>
    <category term="lighttpd"/>
    <category term="clean url"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2006/10/14/rewrite-magnet" rel="alternate" type="text/html"/>
    <title>rewrite + magnet</title>
<content type="html">
            hmm, ok ... another minor bug. if you used mod_rewrite before mod_magnet you would need another line in the cleanurl.lua.

&lt;pre&gt;
--- cleanurl.lua 2006-10-08 09:05:19.000000000 +0200
+++ cleanurl.lua        2006-10-09 08:52:32.000000000 +0200
@@ -17,6 +17,7 @@
         -- file still missing. pass it to the fastcgi backend
         lighty.env[&quot;uri.path&quot;] = &quot;/dispatch.fcgi&quot;
         lighty.env[&quot;physical.rel-path&quot;] = lighty.env[&quot;uri.path&quot;]
+        lighty.env[&quot;request.orig-uri&quot;]  = lighty.env[&quot;request.uri&quot;]
         lighty.env[&quot;physical.path&quot;] = lighty.env[&quot;physical.doc-root&quot;] .. lighty.env[&quot;physical.rel-path&quot;]
     end
 end
&lt;/pre&gt;

The fixed version is now &lt;a href=&quot;/cleanurl-v5.lua&quot;&gt;cleanurl-v5.lua&lt;/a&gt;.
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2006-10-08:14</id>
    <published>2006-10-08T06:48:00Z</published>
    <updated>2007-02-06T22:42:18Z</updated>
    <category term="lighttpd"/>
    <category term="clean url"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2006/10/8/argh-directories" rel="alternate" type="text/html"/>
    <title>ARGH directories</title>
<content type="html">
            &lt;p&gt;
   ok .... the cleanurl.lua as shown in &lt;a href=&quot;/2006/10/6/dr-magneto-vs-mr-404-handler&quot;&gt;&quot;Dr. Magneto vs Mr 404 handler&quot;&lt;/a&gt; has a small issue. 
&lt;/p&gt;
&lt;strong&gt;Directories&lt;/strong&gt;
&lt;p&gt;Why directories? My blog decided to create a directory with the same name as one of my controller and suddenly &quot;/controller/&quot; gave me 404. At the first moment i was ... wtf ... I enabled the last line for debugging and got the pointer. So here we are v4 of cleanurl.lua. :)
&lt;/p&gt;
&lt;pre&gt;
-- little helper function
function file_exists(path)
  local attr = lighty.stat(path)
  if (attr and attr[&quot;is_file&quot;]) then
      return true
  else
      return false
  end
end

-- the magic ;)
if (not file_exists(lighty.env[&quot;physical.path&quot;])) then
    -- file does not exist. check if we have a cached version
    lighty.env[&quot;physical.path&quot;] = lighty.env[&quot;physical.path&quot;] .. &quot;.html&quot;

    if (not file_exists(lighty.env[&quot;physical.path&quot;])) then
        -- file still missing. pass it to the fastcgi backend
        lighty.env[&quot;uri.path&quot;] = &quot;/dispatch.fcgi&quot;
        lighty.env[&quot;physical.rel-path&quot;] = lighty.env[&quot;uri.path&quot;]
        lighty.env[&quot;physical.path&quot;] = lighty.env[&quot;physical.doc-root&quot;] .. lighty.env[&quot;physical.rel-path&quot;]
    end
end
-- fallthrough will put it back into the lighty request loop
-- that means we get the 304 handling for free. ;)

-- debugging code
-- print (&quot;final file is &quot; ..  lighty.env[&quot;physical.path&quot;])
&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;/cleanurl-v4.lua&quot;&gt;download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The little helper saves us a little code duplication.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2006-10-06:13</id>
    <published>2006-10-06T19:25:00Z</published>
    <updated>2007-02-06T22:49:14Z</updated>
    <category term="lighttpd"/>
    <category term="clean url"/>
    <category term="lighttpd"/>
    <category term="mod_magnet"/>
    <link href="http://nordisch.org/2006/10/6/dr-magneto-vs-mr-404-handler" rel="alternate" type="text/html"/>
    <title>Dr. Magneto vs Mr 404 handler</title>
<content type="html">
            &lt;p&gt;
  Jan has been working hard on lighttpd. With version &lt;a href=&quot;http://blog.lighttpd.net/articles/2006/09/23/release-lighttpd-1-4-12&quot;&gt;1.4.12&lt;/a&gt;
  he added a new module called &lt;a href=&quot;http://trac.lighttpd.net/trac/wiki/Docs%3AModMagnet&quot;&gt;mod_magnet&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
  At first glance, mod_magnet might be mistaken for a newer version of mod_cml - and it may seem a better version. 
  So what makes mod_magnet so cool?
&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Firstly, you can modify most request parameters&lt;/li&gt;
  &lt;li&gt;You can avoid creating our own DSL within mod_rewrite to implement -d/-f or even more complex conditionals?&lt;/li&gt;
  &lt;li&gt;
    &lt;a href=&quot;http://www.lua.org./&quot;&gt;lua&lt;/a&gt; is really fast! See this &lt;a href=&quot;http://jan.kneschke.de/projects/lua/&quot;&gt;example&lt;/a&gt;
    from jan and his benchmarks.
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;
 What is mod_magnet &lt;b&gt;not&lt;/b&gt;?
&lt;/p&gt;

&lt;p&gt;
 &lt;strong&gt;Be Warned:&lt;/strong&gt;&lt;em&gt;This plugins is not meant for something like &quot;lua server pages&quot;. This is because 
  The magnet script is executed within the lighty core, therefore EVERY long-running operation is blocking ALL connections in the server.&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;
  For time-consuming or blocking scripts use mod_fastcgi and &lt;a href=&quot;http://jan.kneschke.de/projects/lua/&quot;&gt;friends.&lt;/a&gt;
&lt;/p&gt;

&lt;h2&gt;the problem&lt;/h2&gt;
&lt;p&gt;
  The scenario I use mod_magnet is to provide simple (clean) URLs. With mod_rewrite, you can achieve them rather trivially with:
&lt;/p&gt;

&lt;pre&gt;
  # taken from the drupal .htaccess file
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
&lt;/pre&gt;

&lt;p&gt;So far, lighttpd has lacked this feature....&lt;/p&gt;

&lt;p&gt;.... unlike &lt;a href=&quot;http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html&quot;&gt;apache mod_rewrite&lt;/a&gt;. 
  To quote &lt;a href=&quot;http://httpd.apache.org/docs/2.2/rewrite/&quot;&gt;http://httpd.apache.org/docs/2.2/rewrite/&lt;/a&gt;:
&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;`` Despite the tons of examples and docs,
  mod_rewrite is voodoo. Damned cool voodoo, but still
  voodoo.''&lt;/p&gt;

  &lt;p class=&quot;cite&quot;&gt;-- &lt;cite&gt;Brian Moore&lt;/cite&gt;&lt;br /&gt;
  bem@news.cmc.net&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Do we want another voodoo language?&lt;/p&gt;

&lt;p&gt;Back to our scenario - with Dr Magneto to the rescue!&lt;/p&gt;
  
&lt;p&gt; 
  Anyone spent any time dealing with rails will be used to:
&lt;/p&gt;

&lt;p&gt;
  2006-06-18 21:29:04: (connections.c.1407) Warning: Either the error-handler returned status 404 or the error-handler itself was not found: /dispatch.fcgi &lt;br /&gt;
  2006-06-18 21:29:04: (connections.c.1409) returning the original status 404&lt;br /&gt;
  2006-06-18 21:29:04: (connections.c.1411) If this is a rails app: check your production.log&lt;br /&gt;
&lt;/p&gt;

&lt;p&gt;
  The infamous 404 handler trick rears its ugly head again. So I started with the
  &lt;a href=&quot;http://trac.lighttpd.net/trac/wiki/Docs%3AModMagnet#complex-rewrites&quot;&gt;example shown in the mod_magnet docs&lt;/a&gt;.
  However, like many other users I had problems with luafilesystems. After multiple iterations of the script and a few more 
  changes to mod_magnet, we have a nice and slick version of cleanurl.lua for rails.
  &lt;span&gt;=)&lt;/span&gt;
&lt;/p&gt;

&lt;pre&gt;
-- the magic ;)
attr = lighty.stat(lighty.env[&quot;physical.path&quot;])
if (not attr) then
  -- file does not exist. check if we have a cached version
  lighty.env[&quot;physical.path&quot;] = lighty.env[&quot;physical.path&quot;] .. &quot;.html&quot;
  attr = lighty.stat(lighty.env[&quot;physical.path&quot;])

  if (not attr or (attr and not attr[&quot;is_file&quot;])) then
    -- file still missing. pass it to the fastcgi backend
    lighty.env[&quot;uri.path&quot;] = &quot;/dispatch.fcgi&quot;
    lighty.env[&quot;physical.rel-path&quot;] = lighty.env[&quot;uri.path&quot;]
    lighty.env[&quot;physical.path&quot;] = lighty.env[&quot;physical.doc-root&quot;] .. lighty.env[&quot;physical.rel-path&quot;]
  end
end
-- fallthrough will put it back into the lighty request loop
-- that means we get the 304 handling for free. ;)

-- debugging code
-- print (&quot;final file is &quot; ..  lighty.env[&quot;physical.path&quot;])
&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;/cleanurl-v3.lua&quot;&gt;download&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;
  To use this script, you need a lighttpd build from the 1.4.x branch (in svn). &lt;sup&gt;&lt;a href=&quot;#c1&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; 
  SuSE users can just grab the lighttpd14-snapshot rpms from the
  &lt;a href=&quot;http://software.opensuse.org/download/server:/http/&quot;&gt;server:http&lt;/a&gt;
  &lt;a href=&quot;http://en.opensuse.org/Build_Service&quot;&gt;build service&lt;/a&gt; project. &lt;sup&gt;&lt;a href=&quot;#c2&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; 
&lt;/p&gt;

&lt;p&gt;
  Jan added &lt;code&gt;lighty.stat()&lt;/code&gt; for me. My first 2 versions (&lt;a href=&quot;/cleanurl-v1.lua&quot;&gt;v1&lt;/a&gt;, &lt;a href=&quot;/cleanurl-v2.lua&quot;&gt;v2&lt;/a&gt;)
  cost us 2 uncached stat() calls. The same applies to the 
  &lt;a href=&quot;http://trac.lighttpd.net/trac/wiki/Docs%3AModMagnet#complex-rewrites&quot;&gt;complex rewrites&lt;/a&gt; example using luafilesystems. 
   &lt;code&gt;lighty.stat()&lt;/code&gt; uses the stat-cache of lighttpd. Ideally, the stat() is hit once and than cached. Version two of my script has 
   the advantage of working on plain 1.4.12 already.
&lt;/p&gt;
&lt;p&gt;
  The return value of &lt;code&gt;lighty.stat()&lt;/code&gt; cache allows to distinguish files from directories. My next project will be a customizable 
  mod_dirlisting replacement in lua - with caching of rendered directory indeces and all those funny icon stuff people want.
&lt;/p&gt;
&lt;p&gt;
  As many people complained about the length of the cleanurl.lua script, i add the minimalistic version:
&lt;/p&gt;
&lt;pre&gt;
attr = lighty.stat(lighty.env[&quot;physical.path&quot;])
if (not attr) then
   lighty.env[&quot;uri.path&quot;] = &quot;/dispatch.fcgi&quot;
   lighty.env[&quot;physical.rel-path&quot;] = lighty.env[&quot;uri.path&quot;]
   lighty.env[&quot;physical.path&quot;] = lighty.env[&quot;physical.doc-root&quot;] .. lighty.env[&quot;physical.rel-path&quot;]
end
&lt;/pre&gt;
&lt;h2&gt;Benchmarks&lt;/h2&gt;
&lt;p&gt;
  So how much slower does this make lighttpd? The short answer is &lt;strong&gt;not much&lt;/strong&gt;. I benchmarked my lua script and got about 3200r/s. 
  Without the the mod_magnet script i can get my server to 4200r/s. Does this cost performance? Yes. A whole bunch- but if your server is already 
  pushing over a couple thousand requests a second, you're definitely going to have other issues already. Even the 
  &lt;a href=&quot;http://trac.lighttpd.net/trac/wiki/PoweredByLighttpd&quot;&gt;powered by lighttpd&lt;/a&gt; list in the wiki lists only 100r/s as top.
&lt;/p&gt;

&lt;h2&gt;mod_magnet can do that without sweating: R.I.P. Mr. 404 handler&lt;/h2&gt;

&lt;h3&gt;&lt;a&gt;To build from SVN&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;you need at least a checkout of rev 1378 or greater, and &lt;a href=&quot;http://www.lua.org/&quot;&gt;lua&lt;/a&gt; 5.1.&lt;/p&gt;
&lt;pre&gt;
$ svn co svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x/
$ ./autogen.sh
$ ./configure &amp;lt;your params here&amp;gt;
$ make
$ make install
&lt;/pre&gt;

&lt;h3&gt;&lt;a&gt;SuSE notes&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;
  The user documentation can be found at the &lt;a href=&quot;http://en.opensuse.org/Build_Service/User&quot;&gt;opensuse wiki&lt;/a&gt;.
  Additionally you need the lua51-libs rpm from
  &lt;a href=&quot;http://software.opensuse.org/download/devel:/languages:/lua/&quot;&gt;devel:languages:lua&lt;/a&gt;.
&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href=&quot;http://imajes.info/&quot;&gt;imajes&lt;/a&gt; for making this article a pleasure to read for native english speakers&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2006-10-05:1</id>
    <published>2006-10-05T21:04:00Z</published>
    <updated>2006-10-05T21:05:11Z</updated>
    <category term="general"/>
    <link href="http://nordisch.org/2006/10/5/ok-new-try-on-bloggin" rel="alternate" type="text/html"/>
    <title>ok new try on bloggin</title>
<content type="html">
            yet another try on bloggin, lets see where we get.
          </content>  </entry>
  <entry xml:base="http://nordisch.org/">
    <author>
      <name>darix</name>
    </author>
    <id>tag:nordisch.org,2005-03-04:6</id>
    <published>2005-03-04T16:27:00Z</published>
    <updated>2008-02-25T12:30:16Z</updated>
    <category term="fun"/>
    <link href="http://nordisch.org/2005/3/4/sex-basics" rel="alternate" type="text/html"/>
    <title>Sex basics</title>
<content type="html">
            &lt;p&gt;i finally found a page that it explains it for geeks like me!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.collegesexadvice.com/sex.shtml&quot;&gt;http://www.collegesexadvice.com/sex.shtml&lt;/a&gt;&lt;/p&gt;
          </content>  </entry>
</feed>
