For a while now I have been battling issues with fully qualified urls in my blog posts and pages that link internally back to the blog. There are several scenarios that cause me grief in this regard:
- Adding an additional domain name
Several years ago I registered a new shorter domain name and had both pointed at this blog. One issue with this is links in existing posts served on the new domain having a fully qualified reference using the old domain.
I want all these links to be served as relative addresses.
- Using Windows Live Writer to upload images and link to existing posts
Windows Live Writer is without a doubt a fantastic blog post editor. One issue I have with it however is that it uses fully qualified addresses (based on the blog account address) when it uploads an image for a post or links to an existing post within the blog.
I want these fully qualified references to be saved as relative addresses.
- Using Windows Live Writer when MetaWeblog API over SSL is required
BlogEngine.Net has this wonderful setting that forces MetaWeblog API calls to be over SSL.
This is great because the authentication mechanism for MetaWeblog is like email (POP) in that it uses username/password authentication in clear text over the wire. I don’t like the idea of someone grabbing my credentials when I save a post. In addition to Windows Live Writer using fully qualified address (as mentioned in #2), enabling this setting causes Windows Live Writer uses the https scheme for these addresses. The result of this is that the post is saved into BlogEngine.Net using the fully qualified domain and the https scheme.
I want these references to be (optionally) downgraded to http by making them relative to the current host and scheme.
On a side note, check out www.cacert.org if you want a free SSL server certificate that supports wildcard names.
- Fully qualified http references to an image or link served from an https page
This scenario usually happens because of occurrences of #2 above. Browsers tend to throw warnings if a page is served over https but has references to insecure resources. A reference to an image using a fully qualified http address would be such a case.
I want these internal references to be (optionally) upgraded to https references by making them relative to the current host and scheme.
So far I have manually updated each link back to an existing post as I write an entry in Windows Live Writer in order to make it relative. This caters for most of the above issues but it is laborious and easily overlooked. Nothing can be done about images urls because those url values are injected into the post content when Windows Live Writer saves the post. You would have to then edit the post manually online after posting and this is far from ideal. This also does not take care of fully qualified address already stored in the blog.
The birth of LinkFixer
This is where the LinkFixer extension comes into play. LinkFixer can run its logic whenever an entry is either saved to the blog or served to a client. It updates the src and href attributes of tags that link back to the same blog by making them relative addresses.
The first issue above is taken care of by configuring the extension with a set of alias domains that the blog uses. By default the extension will add the current host name and localhost as a domain aliases. You can specify a specific domain name with or without a host header (www.neovolve.com, something.neovolve.com or just neovolve.com for example) or you can specify a wildcard domain to take care of any host header (such as *.neovolve.com).
Note: This extension does not take custom ports into account and assumes the standard port 80 for http and port 443 for https.
The domain alias configuration of this site looks like the following.

The extension will update any url found in a post, page or comment to make them relative for these configured addresses according to the settings discussed below.

Enabling the Convert on saving setting will cause this extension to change blog entry contents when the entry is saved.
Enabling the Convert on serving setting will cause this extension to change blog entry contents when the entry is served to a client. This entry can be disabled for better site performance for new blogs or blogs where all existing post content has been checked for fully qualified addresses and removed any that are found.
Enabling the Convert to HTTPS setting will upgrade http url references in a blog entry when the current request scheme is https. This is enabled by default due to potential security risks in leaving a resource as unsecured.
Enabling the Convert to HTTP setting will downgrade https url references in a blog entry when the current request scheme is http. This is disabled by default due to potential security risks that this may have on a blogs content. I have enabled this setting on my installation as there is no url or image reference in any blog entry that explicitly requires https.
Installation
You can get this extension from here or download the latest set of BlogEngine.Net extensions from here.
Tags: BlogEngine.Net, Performance