Small Town Coder

sharing code samples for desktop, web, and mobile

BlogEngine GoDaddy Shared Hosting Virtual Root Path Issue

I am hosting this blog using one of GoDaddy's shared hosting plans. As many other BlogEngine users have reported, GoDaddy's hosting platform will include the folder name that contains your BlogEngine installation within the URL of all links generated by BlogEngine. I was experiencing the same issue and after trying several other solutions including additional URL rewrite modules, I decided to modify the BlogEngine Core source code to fix (hack) the problem. BlogEngine controls and widgets generate URL's using the Utils.RelativeWebRoot property as the base of the relative URL to the resource. I opted to rewrite the code in this property to perform an extra sanity check on the relative root folder path returned by the VirtualPathUtility.ToAbsolute function. public string RelativeWebRoot { get { if (relativeWebRoot == null) { string vPath = this.virtualPath != null ? this.virtualPath : BlogConfig.VirtualPath; relativeWebRoot = VirtualPathUtility.ToAbsolute(VirtualPathUtility.AppendTrailingSlash(vPath)); if (vPath == "~/") { if (relativeWebRoot != "/") { relativeWebRoot = "/"; } } } return relativeWebRoot; }} Basically, if the virtual path is configured as "~/" and relativeWebRoot is not equal to "/" then override it with the "/".This code change is working well right now as you can see from examining the URL in your browser. The sub folder in which BlogEngine is installed is not present in the URL. This code change has not been tested in other installation scenarios.