<?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>-= n8v =- &#187; IIS</title>
	<atom:link href="http://n8v.enteuxis.org/tags/iis/feed/" rel="self" type="application/rss+xml" />
	<link>http://n8v.enteuxis.org</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 27 Sep 2011 00:52:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-beta2-18055</generator>
		<item>
		<title>Convincing IIS7 to accept URLs containing plusses (+)</title>
		<link>http://n8v.enteuxis.org/2010/07/convincing-iis7-to-accept-urls-containing-plusses/</link>
		<comments>http://n8v.enteuxis.org/2010/07/convincing-iis7-to-accept-urls-containing-plusses/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 00:16:50 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[IIS7]]></category>
		<category><![CDATA[rewriting]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=383</guid>
		<description><![CDATA[Problem: Old retiring IIS 5.0 web server has been accepting URLs containing plus (+) for spaces instead of %20 for like 74 years. People have the old URLs bookmarked and stuff so they&#8217;ll keep going to them. The content will still exist on the replacement IIS 7 web server. Wouldn&#8217;t it be nice to make [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem:</h2>

<p>Old retiring IIS 5.0 web server has been accepting URLs containing plus (+) for spaces instead of %20 for like 74 years.  People have the old URLs bookmarked and stuff so they&#8217;ll keep going to them.  The content will still exist on the replacement IIS 7 web server.   Wouldn&#8217;t it be nice to make it transparent?</p>

<p>(Not to mention &#8220;foo+bar.pdf&#8221; is sane, but &#8220;foo%20bar.pdf&#8221; reads &#8220;foo percent twenty bar&#8221;, awkwardly. )</p>

<p>The problem is that IIS7 by default considers naked plusses in the URL as scary and <a href="http://support.microsoft.com/kb/942076/">sends a 404.11, URL_DOUBLE_ESCAPED error</a>.  Even if you convince it the URL is OK, it no longer maps plus to space and finds a piece of content.</p>

<p>On the old IIS 5.0 server these URLs both work, serving up the document named &#8220;foo bar.pdf&#8221;:</p>

<pre><code>http://server/foo+bar.pdf

http://server/foo%20bar.pdf

</code></pre>

<p>On the new IIS 7 (Windows 2008) server, the second URL works but the first one gives an error.</p>

<h2>Solution:</h2>

<p>I put this in my application&#8217;s <var>web.config</var> file:</p>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="xml"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span><span class="re2">?&gt;</span></span>
<span class="sc3"><span class="re1">&lt;configuration<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;system.webServer<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;security<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;requestFiltering</span> <span class="re0">allowDoubleEscaping</span>=<span class="st0">&quot;True&quot;</span> <span class="re2">/&gt;</span></span>
    <span class="sc3"><span class="re1">&lt;/security<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;rewrite<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;rules<span class="re2">&gt;</span></span></span>
        <span class="sc3"><span class="re1">&lt;rule</span> <span class="re0">name</span>=<span class="st0">&quot;RewriteUserFriendlyURL1&quot;</span> <span class="re0">stopProcessing</span>=<span class="st0">&quot;false&quot;</span><span class="re2">&gt;</span></span>
          <span class="sc3"><span class="re1">&lt;match</span> <span class="re0">url</span>=<span class="st0">&quot;\+&quot;</span> <span class="re2">/&gt;</span></span>
          <span class="sc3"><span class="re1">&lt;conditions<span class="re2">&gt;</span></span></span>
            <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">input</span>=<span class="st0">&quot;{REQUEST_FILENAME}&quot;</span> <span class="re0">matchType</span>=<span class="st0">&quot;IsFile&quot;</span> <span class="re0">negate</span>=<span class="st0">&quot;true&quot;</span> <span class="re2">/&gt;</span></span>
            <span class="sc3"><span class="re1">&lt;add</span> <span class="re0">input</span>=<span class="st0">&quot;{REQUEST_FILENAME}&quot;</span> <span class="re0">matchType</span>=<span class="st0">&quot;IsDirectory&quot;</span> <span class="re0">negate</span>=<span class="st0">&quot;true&quot;</span> <span class="re2">/&gt;</span></span>
          <span class="sc3"><span class="re1">&lt;/conditions<span class="re2">&gt;</span></span></span>
          <span class="sc3"><span class="re1">&lt;action</span> <span class="re0">type</span>=<span class="st0">&quot;Rewrite&quot;</span> <span class="re0">url</span>=<span class="st0">&quot;{UrlDecode:{REQUEST_URI}}&quot;</span> <span class="re2">/&gt;</span></span>
        <span class="sc3"><span class="re1">&lt;/rule<span class="re2">&gt;</span></span></span>
      <span class="sc3"><span class="re1">&lt;/rules<span class="re2">&gt;</span></span></span>
    <span class="sc3"><span class="re1">&lt;/rewrite<span class="re2">&gt;</span></span></span>
  <span class="sc3"><span class="re1">&lt;/system.webServer<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/configuration<span class="re2">&gt;</span></span></span></pre></td></tr></table></div>


<p>the <code>allowDoubleEscaping</code> directive on line 5 <a href="http://serverfault.com/questions/76013/iis6-vs-iis7-and-iis7-5-handling-urls-with-plus-sign-in-base-not-querystri">solves the first part of the problem</a>, allowing IIS to handle unescaped plusses.  The rewrite rule below passes the requested URI through the <a href="http://learn.iis.net/page.aspx/465/url-rewrite-module-configuration-reference/#String_functions">UrlDecode function</a> (line 15), which thankfully still remembers the time-tested convention of plus equaling space. Now both forms of the URL work.</p>

<p>(I didn&#8217;t really write the rewrite stanza, I just stumbled around with the rewrite URL editor in the IIS Manager until it worked)</p>

<p>Yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2010/07/convincing-iis7-to-accept-urls-containing-plusses/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deny access to .svn directories with IIS</title>
		<link>http://n8v.enteuxis.org/2009/11/deny-access-to-svn-directories-with-iis/</link>
		<comments>http://n8v.enteuxis.org/2009/11/deny-access-to-svn-directories-with-iis/#comments</comments>
		<pubDate>Fri, 13 Nov 2009 21:40:38 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[obscurity]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=295</guid>
		<description><![CDATA[The problem: I like using Subversion to deploy web content to production servers. I check in everything while I&#8217;m working on the development copy, then check out onto the server when it&#8217;s ready. Subversion creates a .svn directory contain readable copies of all your files, which is bad for server-processed files like .php or .aspx [...]]]></description>
			<content:encoded><![CDATA[<h3>The problem:</h3>

<p>I like using Subversion to deploy web content to production servers.  I check in everything while I&#8217;m working on the development copy, then check out onto the server when it&#8217;s ready.</p>

<p>Subversion creates a <code>.svn</code> directory contain readable copies of all your files, which is bad for server-processed files like .php or .aspx that you don&#8217;t want readable by, say, <a href="http://en.wikipedia.org/wiki/Google_hacking">Google Hackers</a>.</p>

<p>I have thought about this before but when I went to do it I couldn&#8217;t find any clear guides online.  I did find <a href="http://serverfault.com/questions/23340/ignoring-svn-directories-under-iis/83480#83480">this question at Server Fault</a>, which is a newish sister of <a href="http://stackoverflow.com">Stack Overflow</a>, which reminds me kind of Experts Exchange but without the suck.  Except that in this case the answers sucked.   So I figured it out and added my answer and am posting it here too:
<span id="more-295"></span></p>

<hr />

<p>&#8220;Don&#8217;t do it that way&#8221; does not answer the question.</p>

<p>Practically, I like having a working copy on the production server, because that way I can make quick changes in production (who has never done that?) and check them back in.  It depends on where you want your security/convenience slider, and in many cases this is a good place.</p>

<p>The standard solution in Apacheland is to leave the .svn files there but tell the web server to never serve them.  Here&#8217;s how to do that with IIS 5 through 7 on Windows NT4 through 2008.</p>

<ol>
<li><p>Download and install <a href="http://www.helicontech.com/isapi_rewrite/">ISAPI_Rewrite</a> &#8212; the Lite version will be enough for this purpose.  There are two versions, version 2 and 3.  Use ISAPI_Rewrite3 unless you need to support NT4.    Also, note the extra <a href="http://www.helicontech.com/isapi_rewrite/doc/sysreq.htm">IIS features</a> you need to enable for Win 2008.<br />
<strong>Warning</strong>&#8211; the MSI installer may stop and start IIS.</p></li>
<li><p>Launch the <em>Helicon->ISAPI_Rewrite3->ISAPI_Rewrite Manager</em> app from the Start Menu.  It makes editing the config file (installed in <em>C:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf</em> by default) easier, but you can also do it by hand.  <strong>note</strong>, the config file in ISAPI_Rewrite2 is named <em>httpd.ini</em> and is read-only by default.</p></li>
<li><p>Add these lines to <em>httpd.conf</em>:</p></li>
</ol>


<div class="wp_syntax"><div class="code"><pre class="apache"><span class="co1"># Deny access to Subversion working copy administrative</span>
<span class="co1">#  directories (.svn) and their contents</span>
<span class="kw1">RewriteRule</span> .*/\.svn\b.* . [F,I,O]</pre></div></div>


<p>Now, any request for a .svn directory or its contents will result in a 404 Not Found from the server.</p>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2009/11/deny-access-to-svn-directories-with-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting PHP&#8217;s GD module to work with IIS</title>
		<link>http://n8v.enteuxis.org/2008/11/getting-phps-gd-module-to-work-with-iis/</link>
		<comments>http://n8v.enteuxis.org/2008/11/getting-phps-gd-module-to-work-with-iis/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 21:26:38 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[Figuring IT Out]]></category>
		<category><![CDATA[GD]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[JPEG]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://n8v.enteuxis.org/?p=106</guid>
		<description><![CDATA[Grrr, this cost me about 10 hours, and was hard to research, so I&#8217;m documenting it here for The Good Of Everyone: Problem I work with PHP on a bunch of different web servers. In this case I needed to resize photos (JPEGs) from Microsoft SQL Server (MSSQL) blobs on a Windows web server running [...]]]></description>
			<content:encoded><![CDATA[<p>Grrr, this cost me about 10 hours, and was hard to research, so I&#8217;m documenting it here for The Good Of Everyone:</p>

<h3>Problem</h3>

<p>I work with PHP on a bunch of different web servers.  In this case I needed to resize photos (JPEGs) from Microsoft SQL Server (MSSQL) blobs on a Windows web server running IIS.  I got stuff working on my local Windows development machine (under Apache, <a href="http://www.apachefriends.org/en/xampp.html">XAMPP </a>rocks BTW), but when I moved to the production server:</p>

<ul>
    <li>the script would silently fail with a 500 error whenever I called a GD function, specifically <code><a href="http://us2.php.net/manual/en/function.imagecreatefromstring.php">imagecreatefromstring()</a></code></li>
    <li>The most common IIS and GD error appears to be when PHP can&#8217;t find the GD DLL at all, which produces a nice message like 


<blockquote>Fatal error: Call to undefined function: imagecreatefromstring() in c:\inetpub\wwwroot\test2.php on line 7
PHP Warning: Unable to load dynamic library &#8216;c:\php\ext\php_gd2.dll&#8217; &#8211; The specified procedure could not be found. in Unknown on line 0 
</blockquote>

This was NOT my problem.  My script kept failing silently, with no output after I called the first GD function.</li>
    <li>IIS has no real error log like Apache.  When my script silently failed, nothing was logged in the Application Event log, PHP&#8217;s <var>error.log</var> or the pathetic <var>c:\WINDOWS\system32\LogFiles\HTTPERR\httperr*.log</var>.
<a href="http://blog.monstuff.com/archives/000179.html">Googling hard</a>, I found I <em>might</em> have luck looking for <a href="http://technet.microsoft.com/en-us/library/cc756146.aspx">&#8220;Worker Process Recycling Events&#8221;</a>, which is apparently Microsoft&#8217;s IIS term for that confusing word &#8220;error&#8221;, but I didn&#8217;t go far down that path.
</li>
    <li>Running my script from the command line using PHP didn&#8217;t produce any visible error either</li>

</ul>

<p>IIS sucks.  Apache&#8217;s error log is <strong>way</strong> better.</p>

<h3>Solutions</h3>

<p>I had to do both these things:</p>

<ul>
    <li><a href="http://www.vbulletin.com/forum/archive/index.php/t-111622.html">Copy the php_gd2.dll to C:\WINDOWS\system32</a>.  Ridiculous, but I have had to do it before with other PHP modules to have them really work.  After I did that, the script would work for <em>small</em> JPEG images.</li>
    <li>Increase the memory_limit in php.ini from 16MB to 32MB, so any whole high-res JPEG from the database will fit uncompressed in PHP&#8217;s memory</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://n8v.enteuxis.org/2008/11/getting-phps-gd-module-to-work-with-iis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

