Commits

Dan Carroll committed d659dab

Finish off initial draft of post, add pages for new tag

  • Participants
  • Parent commits 55185d6

Comments (0)

Files changed (3)

File content/blog/2013/03/iis-no-www.html

 listable: true
 title: Configuring No-WWW for IIS on Azure
 description: >
-    Some tips for configuring setting up IIS' Web.Config file 
+    Some tips for configuring setting up IIS' Web.Config file to ensure a good canonical name.
 created: !!timestamp '2013-03-24 12:00:00'
 tags:
     - windows
 
 Where'd my .htaccess go?
 ------------------------
-[Azure Web Sites](http://www.windowsazure.com/en-us/home/features/web-sites/) use IIS as a web server, not the more common Apache (or Nginx) server widely used across the Unix world.  While Azure handles all of the server setup and maintenace for many cases, you'll still need to get your hands dirty if you need custom handling.
+[Azure Web Sites](http://www.windowsazure.com/en-us/home/features/web-sites/) use IIS as a web server, not the more common Apache (or Nginx) server widely used across the Unix world.  While Azure handles all of the server setup and maintenance for many cases, you'll still need to get your hands dirty if you need custom handling.
 
 One of the big behaviors I needed to maintain in the migration was to continue adherence to the [No-WWW philosophy](http://no-www.org/).  This means making dancarroll.org the canonical name of my site, with www.dancarroll.org redirecting to the no-www version.
 
 
 IIS URL Rewrite
 ---------------
-Luckily, IIS has its own [URL rewriting module](http://www.iis.net/downloads/microsoft/url-rewrite).
+Luckily, IIS has its own [URL rewriting module](http://www.iis.net/downloads/microsoft/url-rewrite).  And, even luckier, Azure Web Sites get this module configured automatically.
+
+To get this set up, you need to create a file named `Web.config` in the wwwroot directory of your Azure deployment.  I was only able to find a few examples of doing no-www redirects for IIS, but all of them hardcoded the domain name in the file.  This wasn't acceptable, as I like to reduce maintenance and use a similar configuration across many different web sites.
+
+Here's what I came up with:
+
     :::xml
     <?xml version="1.0"?>
     <configuration>
       </system.webServer>
     </configuration>
 
+And that's it!  I found that Azure would recognize the file modification and start using it, but you may need to manually restart the site using the Azure management portal.
+
+Bonus Rules
+-----------
+A couple of extra URL rewrite rules I am using that are worth sharing.
+
+### Forcing lowercase URLs
+
+    :::xml
+    <rule name="Convert to lower case" stopProcessing="true">  
+      <match url=".*[A-Z].*" ignoreCase="false" />  
+      <action type="Redirect" url="{ToLower:{R:0}}" redirectType="Permanent" />
+    </rule>
+
+### Redirecting default documents
+For default documents (i.e. index.html), it is nice to redirect a request to `domain.com\dir\index.html` to its parent directory, `domain.com\dir\`.  This also help to ensure there is only a single canonical name for any document.
+
+    :::xml
+	<rule name="Default document - html" stopProcessing="true">
+	  <match url="(.*)index.html" />
+	  <action type="Redirect" url="{R:1}" redirectType="Permanent" />
+	</rule>
+

File content/blog/tags/azure.html

+---
+title: azure
+---
+

File content/feeds/tags/azure.xml

+---
+title: azure
+---
+