<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>webdirect.no</title>
	<atom:link href="http://webdirect.no/feed/" rel="self" type="application/rss+xml" />
	<link>http://webdirect.no</link>
	<description></description>
	<lastBuildDate>Tue, 26 Aug 2008 08:26:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Apache caching with gzip enabled</title>
		<link>http://webdirect.no/linux/apache-caching-with-gzip-enabled/</link>
		<comments>http://webdirect.no/linux/apache-caching-with-gzip-enabled/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:04:21 +0000</pubDate>
		<dc:creator>Morten Jacobsen</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://webdirect.no/?p=44</guid>
		<description><![CDATA[As some of you perhaps have noticed earlier, I&#8217;m using gzip compression through Apache&#8217;s mod_deflate on my mobile web application. Lately I&#8217;ve been working on a new service that load it&#8217;s content from an external XML request, and obviously this made me look for caching possibilities, either for the LWP-request behind the scenes or some [...]]]></description>
			<content:encoded><![CDATA[<p>As some of you perhaps have <a href="http://webdirect.no/web/speed-up-your-mobile-site-tm/">noticed earlier</a>, I&#8217;m using gzip compression through Apache&#8217;s <a href="http://httpd.apache.org/docs/2.2/mod/mod_deflate.html">mod_deflate</a> on my mobile web application. Lately I&#8217;ve been working on a new service that load it&#8217;s content from an external XML request, and obviously this made me look for caching possibilities, either for the LWP-request behind the scenes or some sort of front end, varnish-style caching. </p>
<p>Since my application was developed in Perl and LWP-Simple, the caching options was not to many. Using <a href="http://en.wikipedia.org/wiki/Varnish_cache">Varnish</a> caches was little to extravagant for this solution, so my eyes focused on Apaches own <a href="http://httpd.apache.org/docs/2.2/mod/mod_cache.html">mod_cache</a> module.</p>
<p><a href="http://httpd.apache.org/docs/2.2/mod/mod_cache.html">Mod_cache</a> can handle both memory- and disk caching. </p>
<h3>mod_mem_cache</h3>
<p>With simplicity in mind, I started to implement the memory solution, <a href="http://httpd.apache.org/docs/2.2/mod/mod_mem_cache.html">mod_mem_cache</a>. The amount of different pages needed simultaneous in the cache was not bigger than it would be achieved by allocating roughly 10 MB for this purpose.</p>
<p>The setup was quite easy (<a href="http://httpd.apache.org/docs/2.2/mod/mod_mem_cache.html">read about it here</a>), but it has one serious flaw &#8211; <strong>it does not support caching of compressed files</strong>. I&#8217;m not sure why, I think it has something to do with the order Apache handles these modules. </p>
<h3>mod_disk_cache</h3>
<p>Since I don&#8217;t consider disabling compression an option (<a href="http://webdirect.no/web/speed-up-your-mobile-site-tm/">see why</a>), the next module to try out was the <a href="http://httpd.apache.org/docs/2.2/mod/mod_disk_cache.html">mod_disk_cache</a>. This module caches all text files in a <em>specified directory</em>, valid for the time set in the file&#8217;s header expire time. Here is the setup I ended up using:</p>
<pre>
# your Apache httpd.conf
&lt;IfModule mod_cache.c&gt;
  &lt;IfModule mod_disk_cache.c&gt;
  CacheRoot /tmp/apache-cache
  CacheEnable disk /
  CacheDirLevels 2
  CacheDirLength 1
  CacheIgnoreCacheControl On
  CacheIgnoreNoLastMod On
  CacheIgnoreHeaders Accept Accept-Language Accept-Charset \
     Cache-Control User-Agent Cookie Host Referer
  CacheDisable /images
  CacheDisable /stylesheets
  CacheDisable /javascripts
  CacheDefaultExpire 300
  &lt;/IfModule&gt;
&lt;/IfModule&gt;
</pre>
<h3>mod_disk_cache config explained</h3>
<ul>
<li>The <code>CacheRoot</code> needs to be writeable for your Apache user. </li>
<li>In order to ignore all requests from browsers to <em>not</em> load cached files, I set <code> CacheIgnoreCacheControl On</code> </li>
<li><code> CacheIgnoreHeaders</code> lists all header entities that you want to remove from the cached file to be able to serve the same cached version to many user agents (browser types). The cached file&#8217;s header information contain these parameters if you don&#8217;t list them here, and one difference in those headers results in a new cached version of the same file.</li>
<li><code> CacheDisable </code> specifies directories not intended for caching. All flat files and images are practically served the same way from where they are, this cache function are mainly for dynamically generated content. <em>Like my Perl XML-parsing pages</em></li>
</ul>
<p>For further information, please read Apache&#8217;s highly informative <a href="http://httpd.apache.org/docs/2.2/mod/mod_disk_cache.html">documentation on mod_caching</a>.</p>
<p>I am now happily serving rather sluggish Perl-parsing-scripts blazingly fast from this simple caching mechanism!</p>
<p><img src="http://webdirect.no/wp-content/uploads/2008/08/img_0339.jpg" alt="Fisketur ved Høvringsvannet (Rondane)" title="img_0339" width="440" height="293" class="alignnone size-full wp-image-46" />Fishing at Lake Høvringen, Rondane, Norway</p>
]]></content:encoded>
			<wfw:commentRss>http://webdirect.no/linux/apache-caching-with-gzip-enabled/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Speed up your Mobile Site &#8482;</title>
		<link>http://webdirect.no/web/speed-up-your-mobile-site-tm/</link>
		<comments>http://webdirect.no/web/speed-up-your-mobile-site-tm/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 17:01:24 +0000</pubDate>
		<dc:creator>Morten Jacobsen</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://webdirect.no/?p=41</guid>
		<description><![CDATA[I run a Norwegian quiz site for mobile phones called MobilQuiz. This service is a simple Trivial Persuit-like Quiz where you are presented a question on your mobile screen with a simple link to the answer. Really simple and fool prof.
I have during the last weeks upgraded this service to also consist of a iPhone-ified [...]]]></description>
			<content:encoded><![CDATA[<p>I run a Norwegian quiz site for mobile phones called <a href="http://mobilquiz.no">MobilQuiz</a>. This service is a simple Trivial Persuit-like Quiz where you are presented a question on your mobile screen with a simple link to the answer. Really simple and fool prof.</p>
<p>I have during the last weeks upgraded this service to also consist of a <a href="http://beta.mobilquiz.no/iphone">iPhone-ified version</a>. And since the iPhone functions require some hefty CSS and Javascript-libraries, bandwidth-optimalization comes handy. </p>
<h2>Mod_deflate</h2>
<p>I proxy my Rails-application through <a href="http://httpd.apache.org/docs/2.0/">Apache2</a> and that&#8217;s where this gzip-compression-trick called <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate</a> applies. You have to compile your Apache2-installation with <code>--enable-deflate</code>. When that is done, you could just insert this snippet inside your virtual domain space in <code>httpd.conf</code>.</p>
<pre>
&lt;Location /&gt;
  SetOutputFilter DEFLATE
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$  \
		no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \
    no-gzip dont-vary
&lt;/Location&gt;
</pre>
<h2>Result in bandwidth usage</h2>
<p>Before applying <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate</a> the front page on <a href="http://beta.mobilquiz.no/iphone">MobilQuiz</a> clocked in on <strong>33 KB</strong></p>
<p>
<img src="http://webdirect.no/wp-content/uploads/2008/07/picture-2.png" alt="" title="unoptimized" width="500" height="272" class="alignnone size-full wp-image-42" /></p>
<p>After applying <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate</a> the front page only weights <strong>17 KB</strong></p>
<p><img src="http://webdirect.no/wp-content/uploads/2008/07/picture-3.png" alt="" title="optimized" width="500" height="272" class="alignnone size-full wp-image-43" /></p>
<p><b>That&#8217;s a 48,5% reduction.</b> Not bad, huh?</p>
]]></content:encoded>
			<wfw:commentRss>http://webdirect.no/web/speed-up-your-mobile-site-tm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache rewrite rule for iPhone users</title>
		<link>http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/</link>
		<comments>http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 20:25:26 +0000</pubDate>
		<dc:creator>Morten Jacobsen</dc:creator>
				<category><![CDATA[Mobile]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://webdirect.no/?p=40</guid>
		<description><![CDATA[Like so many others these days I am preparing some of my web pages for iPhone invation. I am using this Apache rewrite rule only on the top level domain to route users to their optimized version. When you visit one of these versions, they are all accessable from any device. This is also what [...]]]></description>
			<content:encoded><![CDATA[<p>Like so many others these days I am preparing some of my web pages for iPhone invation. I am using this Apache rewrite rule only on the top level domain to route users to their optimized version. When you visit one of these versions, they are all accessable from any device. This is also what Apple recommends. </p>
<p><a href="http://www.flickr.com/photos/33215455@N00/1168912199/" title="Free Apple Desktop" target="_blank"><img src="http://farm2.static.flickr.com/1197/1168912199_dfe9578556.jpg" alt="Free Apple Desktop" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://webdirect.no/wp-content/plugins/photo_dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/33215455@N00/1168912199/" title="CAVE CANEM" target="_blank">CAVE CANEM</a></small></p>
<p>
Here is my Apache rewrite rule that I use to</p>
<ol>
<li>check if its an iPhone, redirect to optimized version</li>
<li>Identify the most common browsers by User Agent and redirect them to web version</li>
<li>redirect all others to mobile version</li>
</ol>
<h3>Rewrite rule</h3>
<pre>
<VirtualHost *:80>
ServerName www.mydomain.no

# This enables rewriting in this directory
RewriteEngine On

# Catch iPhone-users first, easiest to discover
RewriteCond %{HTTP_USER_AGENT} .*Mobile.*Safari
RewriteRule ^[\./](.*)$ http://beta.mydomain.no/iphone  [L]

# Catch most familiar web browsers and redirect to web version,
# except Opera Mini and SymbianOS (which identifies itself as Safari)
RewriteCond %{HTTP_USER_AGENT} ((.*MSIE.*Windows\ NT.*)| \
  (Lynx.*)|(.*Safari.*)|(.*Opera.*)|(.*Firefox.*)|(.*Konqueror.*))
RewriteCond %{HTTP_USER_AGENT} !(.*Opera\ Mini.*)
RewriteCond %{HTTP_USER_AGENT} !(.*SymbianOS.*)
RewriteRule ^[\./](.*)$ http://beta.mydomain.no/web  [L]

# Browsers that match neither block, such as regular screen
# browsers, could be caught by a final rewrite rule placed here,
# or we could leave it out and have nothing happen to the
# requested URL. This is the default.

RewriteRule ^[\./](.*)$ http://beta.mydomain.no/mobile  [L]
</VirtualHost>
</pre>
<p>
Notice that it doesn&#8217;t sniff for &#8220;iPhone&#8221;, but &#8220;Mobile Safari&#8221;. This makes also iPod Touch compatible, which currently is the only device using the same browser.
</p>
<h3>Alternative rewrite rule</h3>
<p>This is the old rewrite rule that I used. This should only be used as a starting grid for further development. The WAP-test is not optimal, seems like Nokia&#8217;s and Sony Ericsson&#8217;s latest browsers get identified as ordinary web browsers without WAP-support and as a result gets redirected to the web version.</p>
<p>This set of rules where:</p>
<ol>
<li>check if its an iPhone, redirect to optimized version</li>
<li>check if it doesn&#8217;t support WAP, redirect to web version</strike></li>
<li>redirect all others to mobile version</li>
</ol>
<pre>
<VirtualHost *:80>
ServerName mydomain.no

# This enables rewriting in this directory
RewriteEngine On

# Catch iPhone-users first, easiest to discover
RewriteCond %{HTTP_USER_AGENT} .*Mobile.*Safari
RewriteRule ^[\./](.*)$ http://beta.mydomain.no/iphone  [L]

# Catch XHTML MP browsers first and return XHTML MP content to them
RewriteCond %{HTTP_ACCEPT} !text/vnd\.wap\.wml
RewriteRule ^[\./](.*)$ http://beta.mydomain.no/web  [L]

# Browsers that match neither block, such as regular screen
# browsers, could be caught by a final rewrite rule placed here,
# or we could leave it out and have nothing happen to the
# requested URL. This is the default.

RewriteRule ^[\./](.*)$ http://beta.mydomain.no/mobile  [L]
</VirtualHost>
</pre>
<p>
Please leave a comment if you see or have a smarter way of doing this.</p>
]]></content:encoded>
			<wfw:commentRss>http://webdirect.no/mobile/apache-rewrite-rule-for-iphone-users/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Use Wordpress as CRM system</title>
		<link>http://webdirect.no/web/use-wordpress-as-crm-system/</link>
		<comments>http://webdirect.no/web/use-wordpress-as-crm-system/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 14:14:54 +0000</pubDate>
		<dc:creator>Morten Jacobsen</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[crm]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regexp]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://localhost/project/webdirect2/web/use-wordpress-as-crm-system/</guid>
		<description><![CDATA[Background
I have been looking for a clean and simple CRM solution for my web site for some time. I use this web site more like a sketch block where I ramble down some of my findings and howto&#8217;s mainly for my self. To simplify this process, I wanted to convert my old, file based PHP-site [...]]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>
<p>I have been looking for a clean and simple CRM solution for my web site for some time. I use this web site more like a sketch block where I ramble down some of my findings and howto&#8217;s mainly for my self. To simplify this process, I wanted to convert my old, file based PHP-site to something a bit more dynamic and easily maintainable. I didn&#8217;t do a deep analysis of what&#8217;s available, but I quickly browsed through some alternatives (<a href="http://drupal.org/">Drupal</a>, <a href="http://expressionengine.com/">Expression Engine</a>, <a href="http://www.movabletype.com/">Movable Type</a> and <a href="http://wordpress.org">Wordpress</a>). To make a long story short; I went for <b>Wordpress</b> because of earlier experience with this tool.</p>
<p>It was quite easy to cut&#8217;n paste all my content into its &#8220;pages&#8221; system. The problem arised when I needed to figure out how i could redirect all my .html and .php filenames to folder names that all new systems base their URL structure on. </p>
<p><a href="http://www.flickr.com/photos/84892169@N00/1043966166/" title="" target="_blank"><img src="http://farm2.static.flickr.com/1051/1043966166_b895be3c34.jpg" alt="" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by/2.0/" title="Attribution License" target="_blank"><img src="http://localhost/project/webdirect2/wp-content/plugins/photo_dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/84892169@N00/1043966166/" title="MR+G" target="_blank">MR+G</a></small></p>
<p>Most of the content are from 2000-2003 and all of it are comprehensively crawled by Google and linked up by others. So breaking those links was not an option. Hacking Wordpress to make it possible to use .php and .html endings was not either to smart, both because it was too time consuming and also that I didn&#8217;t wanted to alter Wordpress and make it harder  for me to future upgrades.</p>
<h3>Solution: Rewrite-rules in .htaccess files</h3>
<p>And that&#8217;s really why I wrote this article &#8211; it wasn&#8217;t too much information about this on the web. This is what I wanted to do:</p>
<p>Permantent redirect (301) <code>/linux/mutt.php</code> to <code>/linux/mutt/</code><br />
and remove all index.php so <code>/linux/index.php</code> becomes <code>/linux/</code></p>
<h3>My .htaccess file</h3>
<pre>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Removes index.php-pages
RewriteCond %{THE_REQUEST} \/index\.php(.*)\ HTTP/ [NC]
RewriteRule ^([^.]*)index\.php(.*)$ http://webdirect.no/$1 [R=301,L]

# Externally redirect direct client requests for .php files to non-.php URLs
RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/){1,10}[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://webdirect.no/$1 [R=301,L] 

# Externally redirect direct client requests for .php files to non-.php URLs
RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/){1,10}[^.]+\.html(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.html$ http://webdirect.no/$1 [R=301,L]

# standard wordpress rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</pre>
<h3>Rewrite rules explained</h3>
<pre>
# Removes index.php-pages
RewriteCond %{THE_REQUEST} \/index\.php(.*)\ HTTP/ [NC]
RewriteRule ^([^.]*)index\.php(.*)$ http://webdirect.no/$1 [R=301,L]
</pre>
<p>This one just removes all /index.php from requests and creates a permanent redirect (HTTP 301) so crawles can detect that this page has moved to a new URL</p>
<pre>
# Externally redirect direct client requests for .php files to non-.php URLs
RewriteCond %{THE_REQUEST} ^GET\ /([^/]+/){1,10}[^.]+\.php(\?[^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php$ http://webdirect.no/$1 [R=301,L]
</pre>
<p>Removes .php extensions if the depth of the URL strucure are between 3 and 10 slashes. This to allow some root files to have .php ending, like /login.php for example.</p>
<h3>So, what about .php files from Wordpress?</h3>
<p>Yes, that&#8217;s right. Wordpress uses .php-extention on many internal files that&#8217;s crucial to make the dog fly, and since rewrite-rules in .htaccess files are inhereted, we have to turn off rewriting in some folders (/wp-admin).</p>
<p>This .htaccess file turns of all rewrite rules so Wordpress can function like it&#8217;s meant to in this folder.</p>
<h3>.htaccess file inside /wp-admin</h3>
<pre>
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine Off
&lt;/IfModule&gt;
</pre>
<p>As always, if you know a smarter way to do this, leave a comment, please!</p>
]]></content:encoded>
			<wfw:commentRss>http://webdirect.no/web/use-wordpress-as-crm-system/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
