Sign In  |  Register
 
 
DotNetNuke Support Forums
Using SiteUrls.config to clean-up Child PortalAlias on querystring
Last Post 09 Sep 2009 01:31 AM by CallMeLaNN. 3 Replies.
Printer Friendly
Sort:
PrevPrev
Please Register to post a reply.
Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
John Mitchell
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:4127
Avatar

--
12 Feb 2007 09:14 AM  

Tired of having that ugly qureystring for the home page of your child portals?  DotNetNuke child portals have their own folder under the main website so they can be referenced as a sub-folder, or "child" of the main portal.

To make this work with the rest of the portals, there is code in the default.aspx page that creates an alias parameter that looks something like this: 

alias=www.myhost.com/myportal

This child default page then redirects to the main default.aspx page with that querystring variable, so you end up getting a Url that repeats the hostdomain something like this:

http://www.myhost.com/default.aspx?alias=www.myhost.com/myportal

With the SiteUrls.config file you can have DNN rewrite this Url so that the result looks like you browsed to the child folder without any querystring variable at all.

First, figure out what the tabid is for the home page for the child portal, on mine it was tabid=508, then add a rule to SiteUrls.config like this:

  
LookFor >>    .*/child1/default.aspx
SendTo   >>     ~/Default.aspx?TabId=508
  

Where child1 is the name of your child portal.

You have to leave the child folder and the default page there, because IIS needs to find that before it will call up the web app, otherwise you'll get a 404 page not found.

This keeps your Url nice and clean and you even save the redirect.

You could also make a rule like this and get the same result without having to know the tabid:

  
LookFor >>   .*/child1/default.aspx
SendTo   >>   ~/Default.aspx?alias=www.snapsis.com/child1
  

This is a nice way to clean up the Url for a few child portals, but I wouldn't recommend running it on too many, because every rule that you add to the SiteUrls.config file adds to the overhead of every request no matter what portal you are accessing.

A more efficent way, although not quite as elegant is to just change the child's default.aspx page code so that it redirects directly to the tabid or portalid of the child portal as mentioned in this ASP.Net forums thread.

greenflash
New Member
New Member
Send Private Message
Posts:63

--
20 Feb 2007 09:14 AM  
John thanks for the useful tip, i finally handled creating child portal on godaddy root with your instructions. Thank you very much sir.
John Mitchell
Administrator
Veteran Member
Veteran Member
Send Private Message
Posts:4127
Avatar

--
20 Feb 2007 09:36 AM  
Excellent, glad I could help.

In case anyone else needs to do this, here are the instructions for creating a Child Portal on GoDaddy since they do not allow write permissions to the root folder for DNN.

1. Create a subfolder using the child portal name with the GoDaddy hosting control panel.

2. Create the portal in DNN as a parent portal (creating a parent does not require DNN to create a physical folder).

3. After it is created, go in and change the PortalAlias for that portal so it maps it as the subfolder.

Note: Having a portal alias in the form of mysite.com/childfolder is really the only thing that makes it a "child" portal.

4. Then you will need to copy the subhost.aspx file from the /portals/_default folder into your child folder and rename it to default.aspx
CallMeLaNN
New Member
New Member
Send Private Message
Posts:1

--
09 Sep 2009 01:31 AM  
Hi,

I just found this thread as the first rank of "dnn portal alias query string" keywords. I also found the asp.net forums that John Mitchell said. However I can't reply in the asp.net thread. So I just reply here.

I wondering this things happened since 2003 by ikamiksok in the asp forum and until today, dnn version 5.1.x also have a same result by default settings.

Here I want to share, using the same way, I just modify it to make it more useful.

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. 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
Please Register to post a reply.
Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.


Active Forums 4.1
Visit our Store for great DotNetNuke Modules and Skins
DotNetNuke CSS Menu 3.4.1 (single use)

Item codeCSSNM33SU
AuthorJohn Mitchell
Base Price$39.00
Product Information 
DotNetNuke CSS NavMenu 3.4.1 (Developers)

Item codeCSSNM33DEV
Base Price$149.00
Product Information 
DotNetNuke Performance Caching & Compression - PageBlaster 3.4.5 - Professional Edition

AuthorJohn Mitchell
Base Price$59.00
Product Information