I'm Keyvan Nayyeri, a 28 years old software engineer working at Match.Com and living in Dallas, Texas.
I have a Master’s degree in computer science and a bachelor's degree in applied mathematics. I’m also known to be a technical author with several technical publications in the form of books and articles. Besides, I'm an open source enthusiast and have coordinated or contributed to several projects. Currently, I maintain my projects on GitHub.
As a content provider on the internet, not only I publish on this technical blog, but also I'm a podcaster and publish audio podcasts on Mash This.
Trying to maintain a healthy and active lifestyle, I'm a pescetarianist and exercise almost everyday. I’m an avid runner, soccer defender, and tennis player. I also have an interest in fashion.
It’s obvious that I’m trying to support the wave of NO-WWW! A long time ago I had written a HttpModule to remove “WWW.” from URLs. Last year I wrote a post with some topics for simpler URLs in web applications including an alternative solution to accomplish this task using ISAPI filters in Internet Information Services. Recently I also wrote another post about the issues related to SSL certificates and these extra characters in URLs.
One of the goals that I’m trying to accomplish is collecting all the possible ways to have WWWless URLs in the ASP.NET web applications, and I will keep writing such posts in the future as well. For now, I want to offer the simplest way to accomplish this in ASP.NET and IIS 7.0.
Today I spent some time switching from ISAPI filters to Microsoft URL Rewrite Module for IIS 7.0 and use it as an alternative for ISAPI tasks on Waegis and Nayyeri.NET. As you may know, this module is a very cool addition to the great new features in IIS 7.0 to complement it in one of the most common scenarios which is URL rewriting.
Beside the replacement of URL rewriting mechanism on Waegis (which was previously done with UrlRewriter.NET), I also removed Ionic ISAPI filter to implement Microsoft URL Rewrite module in order to redirect requests to URLs with “WWW.” prefix to the new URLs without it.
Here is the classic configuration of the rule necessary to remove “WWW.” from all the URLs on a domain with a permanent redirect to the new address.

The equivalent manual configuration is this:
<system.webServer>
<rewrite>
<rules>
<rule name="Remove WWW" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
conditions>
<action type="Redirect" url="http://keyvan.ms{PATH_INFO}" redirectType="Permanent" />
rule>
rules>
rewrite>
system.webServer>
But how does it work? First it checks for all the requests defined by the regular expression pattern in
In the second step it checks the rules defined in
In the action I use a redirect task to the new URL which is a combination of my domain name and PATH_INFO parameter that yields my desire result. I also use the permanent redirection which is the recommended redirection type for this case.
James Alvin
Jan 25, 2009 1:19 PM
#
You should try http://www.codeplex.com/urlrewriter. The syntax for it can be written in a more universal method.
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(www\.)(.+)$ [NC]
RewriteRule (.*) http(?%1s)://%2$1 [R=301,L]
The above will take any domain HTTP or HTTPS and redirect to a NON-WWW domain. I like the mod_rewrite way because it doesn't suffer from the angle bracket bloat.
Sam
Dec 31, 2010 4:23 PM
#
Ed Sansbury
Apr 27, 2011 12:14 PM
#
Brian
Nov 02, 2012 12:29 PM
#
Sadegh
Jan 08, 2013 2:49 PM
#
indoor cycling
Apr 19, 2013 6:36 AM
#
Did you develop this website yourself? Please reply back as I'm hoping to create my own personal blog and would love to find out where you got this from or what the theme is named. Kudos!
Pradeep
May 17, 2013 9:24 AM
#
More Info
Jun 02, 2013 11:25 AM
#
to get facts regarding my presentation focus,
which i am going to convey in school.
Leave a Comment