<?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>durdle.com &#187; gradwell</title>
	<atom:link href="http://durdle.com/archives/tag/gradwell/feed/" rel="self" type="application/rss+xml" />
	<link>http://durdle.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Sep 2011 13:33:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>IIS7 web.config fun</title>
		<link>http://durdle.com/archives/2010/03/08/iis7-web-config-fun/</link>
		<comments>http://durdle.com/archives/2010/03/08/iis7-web-config-fun/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 20:15:11 +0000</pubDate>
		<dc:creator>Howard</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[gradwell]]></category>
		<category><![CDATA[iis7]]></category>
		<category><![CDATA[memset]]></category>
		<category><![CDATA[web.config]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[workavoidance]]></category>

		<guid isPermaLink="false">http://blog.durdle.com/?p=747</guid>
		<description><![CDATA[I spent some time last weekend migrating the Work Avoidance site away from Gradwell and onto a dedicated virtual server from MEMSET. Since this involved a move to a Windows box away from UNIX hosting, I had to configure in IIS7 some of the settings I had in the .htaccess under the UNIX host. For...]]></description>
			<content:encoded><![CDATA[<p><a href="/wp-content/uploads/iis7-logo.jpg" rel="lightbox[747]"><img src="/wp-content/uploads/iis7-logo.jpg" alt="IIS7 Logo" title="IIS7" width="200" height="125" class="alignleft size-full wp-image-757" /></a>I spent some time last weekend migrating the <a href="http://workavoidance.net">Work Avoidance</a> site away from <a href="http://www.gradwell.net/">Gradwell</a> and onto a dedicated virtual server from <a href="http://www.memset.com/dedicated-servers/virtual.php">MEMSET</a>.  Since this involved a move to a Windows box away from UNIX hosting, I had to configure in IIS7 some of the settings I had in the .htaccess under the UNIX host.<span id="more-747"></span></p>
<p>For example, I want a canonical host name (so visitors always see <a href="http://workavoidance.net">workavoidance.net</a> with no www prefix in the address bar) and to ensure that the <a href="http://wordpress.org/">WordPress</a> permalinks work properly.  While I was at it I took the opportunity to disable hot-linking of our images, since for some reason a Russian website had taken a shine to some of our <a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=303892009&#038;mt=8">Armory</a> graphics.</p>
<p>Below is the <code>web.config</code> I created.  It redirects users to the canonical host name, enables WordPress permalinks and disables hot-linking of our images.  The redirect proved something of a problem to begin with.  Our iPhone App &#8220;<a href="http://itunes.apple.com/us/app/monkey-shaker/id290779801?mt=8">Monkey Shaker</a>&#8221; has an online <a href="http://workavoidance.net/highscores/shaker/">high score system</a>.  Scores are submitted from the app via an encrypted HTTP POST to a PHP page which decrypts the information and updates the database.  I discovered that when you issue a server side redirect most clients won&#8217;t re-POST their data to the new page &#8211; they will issue a GET for the new page and the original POST data is lost.  This meant that highscore submissions were failing.</p>
<p>(NB: this isn&#8217;t as big a disaster as it sounds since we built a very robust mechanism to retry score submission into the app.)</p>
<p>So, you&#8217;ll note an extra entry in the web.config to exclude that page from a redirect:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{URL}&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;scoresubmit\.php$&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre>
</div>
</div>
<p>&#8220;Why not just change the URL in the app to be canonical?!&#8221; You may well ask.  Yes, we probably will, but that relies on issuing an update and getting <strong>over a quarter of a million users</strong> to download it.  This way we don&#8217;t have to rely on that.</p>
<p>Still to come &#8211; how I implemented caching in WordPress and in our high score system to improve performance.</p>
<p>Here&#8217;s the rewrite rules section of the completed web.config:</p>
<div class="wp_syntax">
<div class="code">
<pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rule</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Canonical Host Name&quot;</span> <span style="color: #000066;">stopProcessing</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;(.*)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;conditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{HTTP_HOST}&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;^workavoidance\.net$&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{URL}&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;scoresubmit\.php$&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/conditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Redirect&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;http://workavoidance.net/{R:1}&quot;</span> <span style="color: #000066;">redirectType</span>=<span style="color: #ff0000;">&quot;Permanent&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rule</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Prevent image hotlinking&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;.*\.(gif|jpg|png)$&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;conditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{HTTP_REFERER}&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;^$&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{HTTP_REFERER}&quot;</span> <span style="color: #000066;">pattern</span>=<span style="color: #ff0000;">&quot;^http://workavoidance\.net/.*$&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/conditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Rewrite&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;/no.png&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;rule</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;wordpress&quot;</span> <span style="color: #000066;">patternSyntax</span>=<span style="color: #ff0000;">&quot;Wildcard&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;match</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;conditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{REQUEST_FILENAME}&quot;</span> <span style="color: #000066;">matchType</span>=<span style="color: #ff0000;">&quot;IsFile&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">input</span>=<span style="color: #ff0000;">&quot;{REQUEST_FILENAME}&quot;</span> <span style="color: #000066;">matchType</span>=<span style="color: #ff0000;">&quot;IsDirectory&quot;</span> <span style="color: #000066;">negate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/conditions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;Rewrite&quot;</span> <span style="color: #000066;">url</span>=<span style="color: #ff0000;">&quot;index.php&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/rule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://durdle.com/archives/2010/03/08/iis7-web-config-fun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

