Saturday, June 29, 2013

DotNetNuke & GoDaddy - How to have nice urls

The Problem

For Week 3 I have been working on setting up DotNetNuke.  I have a Windows shared hosting which isn't so bad but it does have it's quirks.  For instance, it loves to add the directory name into the url.

The common wisdom is to place DotNetNuke in the root of the site but that didn't work for my purposes. (Actually I will end up doing that only because I want to make the site currently in the root in DNN). Keeping DNN in it's own virtual directory has presented itself with some challenges.  Obviously I don't want users to see the /dotnetnuke in the url nor do I want it to be required. After a couple days of trial and error I came up with a solution.

The Solution

Step 1:

Assuming you have a working DNN install, set up a Portal Alias for urls with both the virtual directory and non-virtual directory.

Step 2:

Experience with MVC sites says that we can edit the web.config file in order to add rewrite rules.  In order to do this you must be running in IIS integrated pipeline mode.

Since it seems that the root directory tries to handle url rewrites first (GoDaddy thing?), we must add the following code to the system.webServer section of our web.config in the ROOT of the hosting account.

 <clear />
       <rule name="Remove Virtual Directory">
          <match url=".*" />
          <action type="Rewrite" url="{R:0}" />
        <rule name="Rewrite DotNetNuke to Root" stopProcessing="true" enabled="true">
           <match url="^dotnetnuke$|^dotnetnuke/(.*)$" />
           <action type="Redirect" url="{R:1}" redirectType="Permanent" />
        <rule name="Rewrite Root to DotNetNuke " stopProcessing="true" enabled="true">
           <match url="^(.*)$" />
           <conditions logicalGrouping="MatchAll">
  <add input="{HTTP_HOST}" negate="false" pattern=".+\.oneweekonewebsite\.com$" />
  <add input="{PATH_INFO}" negate="true" pattern="^/dotnetnuke$|^/dotnetnuke/(.*)$" />
           <action type="Rewrite" url="dotnetnuke/{R:1}" />

Rule Descriptions:
  1. Rewrite the url to itself.  This is interesting in that it creates an X_ORIGINAL_URL server variable which MVC uses to populate it's routes. This will get rid of the virtual directory on a normal MVC site.
  2. Look for the virtual directory name and redirect to the url without it.  This will get the user's browser to display our nice url if they come from one that includes the virtual directory.
  3. Rewrite a url without the virtual directory to one with the virtual directory. The rewritten url is only used internally by the server so the user won't see this. This will make it so the server matches the request to a request to dnn.  Notice how I added a condition for my domain.  I have multiple domains but is the only one running DNN and I don't want the others to be picked up by it. The regular expression will send any subdomains to DNN.  The second condition will also prevent any urls already containing the virtual directory name from having it added again.
Update: In order for everything to work, your domain should point to the root of the hosing account NOT the virtual directory.

Step 3:

???  I really thought this was more complicated than it is with all the time I spent on this.  Hopefully I can save others some time.  I guess step 3 is just profit.

One thing that would be good is to get a FriendlyURL module. All the links on the site will still have the virtual directory in them but users will hardly ever notice them since when they click on them they will be redirected to the nice name.  Outbound rewrite rules would work if you run your own server but GoDaddy only has version 1.1 of the URLRewrite Module. If we could get them to upgrade to 2.0 we would be able to rewrite urls in links.

Friday, June 28, 2013

Week 1.5 - Great start, great feedback

Getting some great feedback on this project.  Lots of people watching me so that makes me nervous on delivering.

Week 2's site looks all set. I'll just do the deploy and testing this weekend. If you have a Visa or other debit card gift card this site might be for you.

Week 3 is also coming along nicely.  It will be a setup of DotNetNuke with a conversion of an existing site I have into DotNetNuke.  DotNetNuke will hopefully allow me to build content based sites easier.

Monday, June 24, 2013

Week 1 -

Let's Get this Started

In order to best track this project we need a site for progress. If you are reading this, you've found it.

The first site makes sense to be the one to hold them all together.  A nice slow start also gave me time to setup the domain and hosting and all that fun stuff so I don't have to do that when things get busier.

This site is simply a Blogger blog. You'll be able to follow posts on what is happening and view the List of Websites. I'll also use it to gather feedback and suggestions or ideas for future weeks.

If you have any tips for what you would like to see here, leave them in the comments below.

Week 0 - What is going on here?


I love building websites. I love putting something together and standing back to look at the results. While I do web development as my day job, I really wanted a project to call my own and that would be both challenging and interesting. That is why I am challenging myself to develop one website in one week for the next 52 weeks or more. I've seen only a couple of others attempt this. One only has the first week finished.  Another, David W Clary, looks to have been highly successful, having completed 10 weeks before become too busy developing sites for others. No regrets as long as I work my best.


  • Create a website, app, blog, etc. each week so it is available by Monday morning.
  • I'm a developer, not a designer so function over form but I should try to improve my art skills.
  • Learn new technologies, have fun.
  • Try to get some of those ideas in my head out into the wild to make room for more ideas.


As a reader you can help and participate in multiple ways:
  • Check out each site Monday morning and leave comments and feedback.
  • Sharing sites or this challenge with your friends.
  • Writing me nasty letters if the site isn't up.
  • Coming up with ideas of sites, nothing you wouldn't want your grandma to see.
If you have an idea for a site I will post when I need suggestions.  If you have a particular site that you need for yourself or company, contact me at anytime and we can work out a deal for me to build it and feature it on OneWeekOneWebsite.