How to use IIS7 to rewrite URL’s and remove the www.
I’m not sure why, but I’ve grown to dislike the www. in front of websites. I think it’s because it’s pretty superfluous now. Sure one could just type coreygo and press CTRL+Enter and FF or IE adds everything in. But it’s nice to have a bit more control server side and ensure that everyone goes to the same URL. It’s also nice to prevent double entries in search engines and all that that entails.
If you’re using some LAMP type set up you could always just use mod_rewrite with .htaccess and just do:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
IIS7 can actually import a .htaccess file and does a good job of converting them over. However if you just want to do the same thing from scratch the quickest way is to pop open the web.config for the website (you can create one if it doesn’t exist) and add the rewrite rules. Here’s my complete web.config as an example:
< ?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system .webServer>
<rewrite>
<rules>
<rule name="Redirect www." stopProcessing="true">
<match url="^(.*)" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" negate="true" pattern="^$" ignoreCase="false" />
<add input="{HTTP_HOST}" negate="true" pattern="^coreygo.com" />
</conditions>
<action type="Redirect" url="http://coreygo.com/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system>
</configuration>
Just replace coreygo.com with your own domain and that’s it. I’ve got the bindings set up for this site so there’s just www. but this would also redirect blogs. if that was included as a binding. There’s a way to make exceptions and such but for that head over to IIS.net
.

Yay, good speeds with a static IP!!!

