On a recent project our team worked on I was told that integrating your blog into your existing website as opposed to configuring it as a sub-domain is much better for SEO. I never thought that the page ranking of the parent domain would not reap the benefits of a child domain. Our old blog lived at blog.cloudconstruct.com, and the other day I moved it to www.cloudconstruct.com/blog so we could take advantage of the traffic coming to our blog for our company website page rankings.
We use BlogEngine.Net as our blog provider and it has worked pretty well so far. Very easy to setup, lightweight, and very configurable. My first thought on moving the blog was to setup a virtual directory under our website root and point it to the BlogEngine.Net root. As I started with this I realized that BlogEngine.Net was running under .NET 3.5 and our Cloud Construct website was using .NET 4.0. To get past this I just configured the virtual directory to run under .NET 2.0 in IIS (there is no 3.5 option) and pointed it to a separate application pool than the parent application which was at 4.0. Lastly, I set the old blog site to do a 301 redirect to the new URL. This is the recommended method of handling a permanent redirect so search spiders and bots can properly crawl and index your sites.
I figured I was all good so I hit the new blog link and WHAM!, .NET runtime error. It was complaining it did not understand what targetVersion="4.0" in the web.config was. I thought to myself why is it looking at the parent web.config. Then I remembered that in .NET child applications always inherit settings from their parent applications. The blog application could not understand the new settings or runtime attributes because it was running under .NET 3.5.
The way to fix this issue is to add a location node around the node in the parent web.config and add the attribute inheritInChildApplications="false" on the location node. Your parent web.config should look like this:
I refreshed the page and the blog came up. Great! I started to navigate through the blog to make sure all the links worked as expected and ran into some basic security issues where I just had to grant some write permissions to various files the blog writes to. I then clicked the Home link and got a 404 page not found error. The URL was www.cloudconstruct.com/blog/. I began by setting up the default document to be default.aspx so the URL would resolved when the page was not supplied. I tried again and the page still could not be found.
For some reason my default document setting was not getting picked up. I tried for awhile (about an hour) to figure out why this was happening and could not fix the issue. Finally I resorted to just setting up another basic HTML site and testing to see if there was something with IIS 6.0 and default documents resolving in virtual directories. This ended up working fine. Next, I googled a bit and found someone who had posted a blog entry on .NET 3.5 and virtual directories. They were saying that default documents would not resolve in virtual directories running under .NET 3.5 if the actual document was not present in the web root. I guess .NET 3.5 makes sure the document exists before sending the user there. Since my blog was linked from another directory on the server I put a blog directory under the web root with a file inside called default.aspx. This didn't work either!! It was getting late and I was ready to revert the blog to it's original location.
The last thing I thought was maybe it had something to do with the mixed .NET versions. I added a virtual directory for a site running under .NET 3.5 and this worked fine. Hmmm, I deleted the blog virtual directory and re-added it. This time I did not set the .NET runtime to 2.0 and also did not put the application in a separate application pool. I hit the URL www.cloudconstruct.com/blog and it worked!
I guess this is a good thing that the blog was now integrated and working but in my mind I couldn't help but worry the two applications would have problems being in the same application pool and also the child application not having it's .NET runtime properly set. As I write this entry I ask anyone who knows a little more about IIS and web.config setting to provide some insight on this strange configuration. Any comments would be appreciated and I hope this article helps users trying to integrate their blogs into their sites.
About the Author:
Arra Derderian serves as the President and as a Lead Technical Architect for Cloud Construct. As a founder at Cloud Construct, Arra is involved in all levels of the business from new project engagements, project planning, and development.
He also serves as the founder of the Boston Orchard CMS User Group and is a member of the Windows Azure Insiders group.
Arra graduated from Northeastern University School with a Bachelor of Science degree in Computer Science.