using a Virtual Directory

Oct 18, 2007 at 4:16 PM
Edited Oct 18, 2007 at 4:42 PM
I setup Blogengine as a virtual directory (website is, virtual directory is 'blog', url is There is an issue with relative and absolute urls for links and objects.

Images are save in the /images/ directory within the BlogEngine virtual directory which equates to

When creating a post with links or images, urls have 3 options: relative (images/1.jpg), root relative: (/blog/images/1.jpg), and absolute: ( It turns out that relative URLs are NOT an option because BlogEngine changes images/1.jpg to /blog/admin/pages/images/1.jpg which doesn't exist. ALSO, absolute URLs are NOT an option because BlogEngine strips the absolute part, becomes /blog/images/1.jpg. The only option that work is /blog/images/1.jpg.

This works fine on the website, but causes problems for rss feeds. The blog syndication.axd adds absolute URLs to all links within the post. What happens is the LINKS to images (thumbnail links to full size image) are changed from /blog/images/1.jpg to, which does not exist. The img src is not changed, however, which is fine when the content is served from, but in our case the feed goes through FeedBurner ( is CNAME for Feedburner; FeedBurner serves content from syndication.axd). So embedded images refer to which doesn't exist AND links to images refer to, which does not exist.

With the confusion of relative,root,directorys,etc. the normal solution is to use absolute URLs for images and links, but BlogEngine somehow strips them out. How can we resolve?

Anyone using a virtual directory and providing an rss feed will have some issues, unless I'm mistaken.

I am willing to modify the source and recompile if feasible. Thanks!

P.S. BlogEngine.VirtualPath" value="~/"
When I try "~/blog/" all links become
Oct 18, 2007 at 6:07 PM
You most likely set up your root as virtual directory with name of "blog" and then have subdirectory "blog", this is why "~/blog" returns "/blog/blog".
Oct 18, 2007 at 7:57 PM

rtur wrote:
You most likely set up your root as virtual directory with name of "blog" and then have subdirectory "blog", this is why "~/blog" returns "/blog/blog".

I'm not sure I follow, but just to be clear, there is no physical directory /blog/. The root of the (the one with web.config, error404.aspx, etc), is setup as a virtual directory named blog under an existing website. The blog then resides at

I have devised a fix for this situation by modifying SyndicationGenerator.cs as follows:

In the function ConvertPathsToAbsolute(string content), change this line:
content = content.Replace("href=\"/", "href=\"" + Utils.AbsoluteWebRoot);
content = content.Replace("href=\"/blog/", "href=\"" + Utils.AbsoluteWebRoot);
And add the line:
content = content.Replace("src=\"/blog/", "src=\"" + Utils.AbsoluteWebRoot);

In order for this to work, all images and links must be referred to as a root relative link (/blog/images/1.jpg). Also, /blog/ is specific for my application, so if your virtual directory is something different the code would have to modified accordingly.

This may seem like a minor bug, but if you have a lot of people subscribing to your feed, it becomes major. Hopefully a permanent fix can be developed.

Oct 18, 2007 at 9:17 PM
The reason it does "/blog/blog/" when you use "~/blog" is because it's an application starting point in IIS. In ASP.NET the ~/ does not have the same function it would in a non-ASP.NET application. Typically, "~/" would take you to the root of your Web site. However, in ASP.NET it takes you to the root of your application which is already "/blog/". So, in other words, you should be able to just use "~/" and it will build links with "" automatically. Your code would look like this:

content = content.Replace("href=\"~/", "href=\"" + Utils.AbsoluteWebRoot);