Redirect domain names using UrlRewrite.NET

by admin 30. October 2007 11:43

UrlRewriter.NET is a great tool for url rewriting in .NET. It can even be used to redirect domain names with.

e.g. RikPVR's main address is http://www.rikpvr.com/, but it can also be found at http://www.rikdvr.com/,http://rikdvr.com/ or http://rikpvr.com/ but ideally these should just redirect to the primary address. Using a host condition in UrlRewriter.NET makes this easy:


<if header="HOST" match="^((www.rikdvr.com)|(rikdvr.com)|(rikpvr.com))$">
<redirect name="RikDVR" url="^(.*)$" to="http://www.rikpvr.com$1" />
</if>

Comments (3) -

10/10/2008 2:19:50 AM #

marco

Thanks for the tip. You saved me a lot of time.

marco

10/13/2008 6:19:16 PM #

Abraham Luna

This code isn't working. I enter domain.com and get redirected to domain.com/www.desireddomain.com/Default.aspx

Abraham Luna

7/11/2009 12:28:11 AM #

Det er også fordi det skal gøres således Smile

<add name="DomainRedirect"
virtualUrl="^http://domain(.*)$"
destinationUrl="http://www.domain$1"
redirectMode="Permanent"
rewriteUrlParameter="ExcludeFromClientQueryString"
rewrite="Domain"
redirect="Domain"
ignoreCase="true"
/>
[/code]

Scott Hugh Alexandar Petersen

Comments are closed

About Us

RikWare is a software development company based in Brisbane, Australia. Led by director, Richard Mason, RikWare focusses on solving challenging business problems promptly and effectively.

RikWare is also the owner of Aussie Bushwalking, a free, wiki-like collaboration site for bushwalkers and the creator of RikMigrations, a migration framework for .NET.

Aussie Bushwalking

Want to discover some new bushwalking ideas? Share a few of your own? Aussie Bushwalking is like Wikipedia... but for bushwalkers. Head on over. Anybody can see the walks and it's free to sign up and share your own.

 

RikMigrations

RikMigrations is a database migration library for .NET based on the migrations facility provided by Ruby on Rails. It allows simple upgrading and downgrading of databases using .NET code (such as VB or C#) either from the command line or built into your application. Unlike many other migration frameworks, RikMigrations is a stand-alone library which does not rely on a large surrounding framework.