Hi,
I found this problem yesterday and until today I found only in ASP.NET and snapsis.com in the past few years. Until DNN 5.x now, it still redirect. I am not sure if it considered not an issue or have a n option to enable/disable. I not found the realted issue anywhere else and this DNN forum today.
This happened when we go to http://www.domain.com/childportal/ and it will redirect to http://www.domain.com/Default.aspx?alias=www.domain.com/childportal.
But this will not happened when we go to http://www.domain.com/childportal/Home.aspx (Human friendly enabled)
Both this three link refering the same home page of child portal but this redirection have some problem. The most important is it was not a good idea for SEO and user will get confused. I am not sure about creating new parent portal whether http://www.domain2.com/ will redirect to http://www.domain.com/Default.aspx?alias=www.domain2.com. If happened, surely it is a bad idea.
Based on that links, the curent solution is using url rewriting and most have problem if we want to handle much child portal.
Here I want to share the better solution I modify from them:
Before that I want to tell the interested things in regex to perform url rewriter. Opening and closing bracket "(" and ")" called capturing group used to 'capture' anything inside it so that we can grab the value. In this url rewriter, we use capturing group in LookFor to copy the child portal name to SendTo url, paste by using $number format where number is the capturing group #. Its useful if we have many child portal that is difficult to add in the SiteUrls.config one by one.
This is my problem because I want to make a lot of child portal, each represent as a specific language site, mirror to the main portal. DNN 5.1.x still not 'fully' multi language to the end user including menu caption and text/html content. (I notice that it will be start to implement in 5.2.x).
In a basic use like this:
LookFor > http://www.domain.com/([^/]*)/Default.aspx
SendTo > ~/Default.aspx?alias=www.domain.com/$1
[^/]* means any letters except "/". We should use this instead of .* because it accept any letters including "/" and we want to make sure it is not a child-child folder or even /TabId/123/Default.aspx that is need to pass to the last SiteUrls.config rule for TabId. You can see the () is the place of child portal, it will be copied to $1. Note that I include absolute url from http... instead of */([^/]*)/Default.aspx because we need to consider http://www.domain.com/path1/path2/path3/Default.aspx also is a match.
Simply you can change like this if you consider about https:
LookFor > (?:http://|https://)www.domain.com/([^/]*)/Default.aspx
SendTo > ~/Default.aspx?alias=www.domain.com/$1
Note that (?: ) is non capturing group. So this () will not counting and $1 remain refer to the second (), child portal name.
We are done.
By using this single rule we can map all child portal to its alias query string.
Now in advance way. Sometimes I want to use the DNN site locally and do some testing. So we also need to copy the host url www.domain.com to the SendTo because it can be localhost or 127.0.0.1.
So this is the result:
LookFor > (?:http://|https://)([^/]*)/([^/]*)/Default.aspx
SendTo > ~/Default.aspx?alias=$1/$2
The second and third () is the host name and child portal name will be copied to $1 and $2 respectively. You can replace second () host name by checking valid url regex. I think it is not important and will make url rewriter more work, just make sure there is no "/" in the host url.
Another problem, normally in localhost we are not using the site in default website (http://localhost/) instead we put it in virtual directory so that more than site can be testing in the local (http://localhost/DNNSite). So we need to add exception for localhost with virtual directory. As a result ([^/]*) will become (localhost/[^/]*|127.0.0.1/[^/]*|[^/]*). It will tell url rewriter to check for localhost/[^/]* first then 127.0.0.1/[^/]* and lastly [^/]*.
The end result is:
LookFor > (?:http://|https://)(localhost/[^/]*|127.0.0.1/[^/]*|[^/]*)/([^/]*)/Default.aspx
SendTo > ~/Default.aspx?alias=$1/$2
By using this single rule we can map any host including:
http://www.domain.com/de/ to http://www.domain.com/Default.aspx?alias=www.domain.com/de
http://www.domain.com/fr/ to http://www.domain.com/Default.aspx?alias=www.domain.com/fr
https://www.domain.com/fr/ to https://www.domain.com/Default.aspx?alias=www.domain.com/fr
http://localhost/DNNProject/fr/ to http://localhost/DNNProject/Default.aspx?alias=localhost/DNNProject/fr
http://127.0.0.1/DNNProject/fr/ to http://127.0.0.1/DNNProject/Default.aspx?alias=127.0.0.1/DNNProject/fr
as well as http://www.domain.com:8080/jp/ to http://www.domain.com:8080/Default.aspx?alias=www.domain.com/jp (not tested but sure)
However this is complex rule and the performance affected is higher because each page loading need to perform the regex match this rule and the others. You can choose either one solution that suite to your site. If you consider for performance then you need to do something with Default.aspx inside each child portal folders which is responsible to redirect the url to main portal ~/Default.aspx?alias=.
CallMeLaNN