Posts Tagged Windows Server 2008

Windows 2008, IIS 7, and URL Rewrite

The migration is finally complete.  This site is now on Windows 2008 courtesy of Softsys hosting. It’s running a little sluggish now, but, that aside, all other issues have been resolved.  I got the impression that this was the first time they had really used Windows 2008. That may sound harsh, but until my migration, they’d never setup something as simple as a custom php.ini file.

But, that said, their support team is extremely responsive so I forgive them.

The reason I switched to Server 2008 was to take advantage of the native URL rewriting capabilities in IIS 7. While handled fundamentally different than mod_rewrite, the same effects can be accomplished. This is important to me since I run WordPress and desire those oh-so-sought-after pretty permalinks.

To learn how to set this up yourself, read this guide on IIS.net.

Or just add the following to your web.config file:

<rewrite>
    <rules>
        <rule name="Main Rule" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="index.php" />
        </rule>
    </rules>
</rewrite>

It’s that easy. This obviously goes in the <configuration><system.Webserver> portion of web.config.

Now, onward and upward!

Update: It gets better/worse. (10/17/2008)

I found a number of settings that are incorrect.

  1. fastcgi.logging was set to 1. It is supposed to be set to 0.
  2. memory_limit was set to 8M. Sources I found said to set it as high as 256M.  I chose 64M as this is not my server and I’d like to remain friends with my host. (Same source as above)
  3. Worst of all, PHP was installed with thread safety. This article from IIS.net clearly says that FastCGI handles thread safety and enabling it will decrease performance.

I have opened up a support ticket to get the last issue resolved. The other settings were modifiable from php.ini.

Current Issues I’m Working Through:

  • Performance is terrible. I suspect this is due to thread safe PHP being installed. (see above)
  • Almost all php errors result in a 500 error, even ones that are logged.
  • URL rewriting is pushing clifgriffin.com/blah to clifgriffin.com/index.php/blah, but everything dies with a 500 error.
  • Installing Permalink Validator plugin fixes above *slightly*. Bad urls results in some wordpress 404s, but URLs like clifgriffin.com/elderly fail with a 500 error. (No php errors are logged) Also, Permalink Validator breaks comment submission and some admin pages…they never come back after they submit. I’d like to know why it partially fixes the problem…might give me a clue to how to totally fix the problem.
  • WordPress doesn’t seem to be able to enforce my www. preference. Going to www.clifgriffin.com does not redirect to clifgriffin.com as expected.

That’s about it. I will try to update this post when I find a solution as there seems to be very little online documentation of these types of problems.

Update: It gets better…but not with IIS (10/20/2008)

After working with softsys multiple hours each day and seeing no resolution, I decided to ditch softsys in favor of mediatemple.net. So, I’m back on unix. Which isn’t to say I have anything against IIS 7. I’m fairly confident my problems were solely configuration problems attributable to my host.

My new plan costs more but is much higher quality than any hosting service I’ve gone with in the past…so I’m excited.

, , , ,

7 Comments