<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>lighty's life: Spice up for error page</title>
    <link>http://blog.lighttpd.net/articles/2005/08/28/spice-up-for-error-page</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>Spice up for error page</title>
      <description>&lt;p&gt;lighttpd isn&amp;#8217;t beautiful when it shows the user that a file is &lt;a href="http://www.lighttpd.net/not-exists.html"&gt;not available&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;When I wrote it I want to make sure to don&amp;#8217;t show any information that might be used for &lt;span class="caps"&gt;XSS&lt;/span&gt; attacks like displaying the &lt;span class="caps"&gt;URL&lt;/span&gt; unencoded, show local paths, ... something like that. I used the simplest approach: Just show the status.&lt;/p&gt;


	&lt;p&gt;This is not pretty, but works. But I assume you want something more sexy.&lt;/p&gt;
&lt;p&gt;There are two ways to handle the output of a error page.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;server.errorfile-prefix&lt;/li&gt;
		&lt;li&gt;server.error-handler-404&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The first is used to use a local, static file as the payload for the status pages.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;create a directory &lt;/li&gt;
		&lt;li&gt;put into that directory a file name &lt;code&gt;404.html&lt;/code&gt;&lt;/li&gt;
		&lt;li&gt;set server.errorfile-prefix do the directory name including the trailing slash&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;The file has to be a static &lt;span class="caps"&gt;HTML&lt;/span&gt; file (no &lt;span class="caps"&gt;PHP&lt;/span&gt;, ...). &lt;strong&gt;thinking&lt;/strong&gt; If you already have a set of nice looking error-pages perhaps you can provide them for other users. The lighty-errorpage-theme-packages.&lt;/p&gt;


	&lt;p&gt;The other way is to use the error-handler which only works for the file-not-found case. The job of the error-handler is to do something intelligent with the request. Possible use-cases are:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Use http://www.example.org/search%20term as the direct entry to the search-page like in &lt;a href="http://php.net/upload"&gt;http://php.net/upload&lt;/a&gt; or &lt;a href="http://dev.mysql.com/slow%20query%log"&gt;http://dev.mysql.com/slow query log&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;Use http://www.example.org/cached-page to do simple caching. If the requested file doesn&amp;#8217;t exist, let the handler generate it. The next request will get the static version.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;This makes it pretty flexible.&lt;/p&gt;</description>
      <pubDate>Sun, 28 Aug 2005 23:59:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:3c046ce21cad50e152f05f8a7b228993</guid>
      <author>jan</author>
      <link>http://blog.lighttpd.net/articles/2005/08/28/spice-up-for-error-page</link>
      <category>unleashed</category>
      <category>errorfiles</category>
      <trackback:ping>http://blog.lighttpd.net/articles/trackback/17</trackback:ping>
    </item>
  </channel>
</rss>
