IIS7 URL Rewrite – Remove www from all urls

I’ve always used the canonical rule template on IIS rewrite to force a www prefix on my urls. Recently I’ve started setting up sites that do the opposite – force no www in the front. Easy enough to do if you have nost headers configured, just select which host name to force to and bam, done.

Now I have a project that is a single web app mapped to an IP. Im running orchard 1.3x on it, so the multi-tenant module allows quick configuraiton of a new site. With the dedicated IP, I don’t have to mess with adding host headers every time I need to create a new site- just set it in DNS and away we go.

The problem with this scenario is – I still had to go into IIS and configure canonical url rules for each new site. What would be nice is to just set one rule that says “strip the www off ANY url coming to this site”.

 

I found the basics for this rule elsewhere on the web, and tuned it to do exactly that:

 

<rule name=”Remove www” stopProcessing=”true”>
  <match url=”(.*)” ignoreCase=”true” />
  <conditions logicalGrouping=”MatchAll”>
    <add input=”{HTTP_HOST}” pattern=”^www\.(.+)$” />
  </conditions>
  <action type=”Redirect” url=”http://{C:1}/{R:0}” appendQueryString=”true” redirectType=”Permanent” />
</rule>

 

Add this in your rules section of the web.config file and you’ll be good to go.

How to add a password to a zip file

I used to use winzip back before it became a bloated absolute garbage piece of an app, and it was my no-brainer way of adding a password to a zip file whenever I needed to do so. Recently I needed to add a password to a zip I needed to email to someone, and in the process discovered that windows 7 no longer has the option to add the password (like windows xp had). Strange. Quickly decided that firing up xp mode (virtual pc) just couldnt possibly be the answer. I have winrar installed, so tried it, but couldnt find a way to do this either. Quick search revealed that 7zip has password capabilities. So I go download and install it.

I already had zipped my content into a zip file, so I just opened this in 7zip so I could add the pw – but no luck. I look through every menu and find nothing. Reading through the help file, I find references to adding the password on the commandline… so I started to think that maybe the commandline is the only way the password can be added. Argh.

Finally an associate showed me that you can select all the files you want to zip, right click on them, select 7zip, and select Add to archive. This pops up a “new archive” window that… sure enough… has the password settings right there in front of you.

Frustrating experience, but lesson learned, and best of all: I don’t have to use winzip.