DotNetNuke Powered!
          
John Mitchell's (mostly DotNetNuke) Blog - DotNetNuke Portal Alias explained
 Sunday, October 09, 2005

Portal Alias, What is it?

In a nutshell, the PortalAlias is used to determine exactly which portal in your DotNetNuke installation is being requested.

A little History
This feature it a pretty important piece of the DNN pie since hosting multiple portals under one IIS website and one set of website files and one Database is one of the best features of DNN (imho). As a matter of fact, this feature was probably the most attractive added enhancement to the IBuySpy workshop, and in DNN 1.x & 2.x the way it worked didn't change much if at all. Then in 3.x we added the ability to have Wildcard portal aliases.  This latest feature was often requested because people wanted the ability for a specific portal to "catch" all the traffic that was directed for a particular domain name.  This would in turn allow them to be able to have portal1.domain.com, portal2.domain.com, portal3.domain.com, etc.,  all running off the same portal.  Putting a manual entry into the Alias table for each of these would have worked, but it would be even nicer if someone could just put domain.com, or *.domain.com.  So we made it so.

No more DotNetNuke Configuration Error
We also realized that as long as we were adding a wildcard feature, that we should probably get rid of the dreaded message that you had somehow royally messed up your portal, just because someone happened to navigate to your site with  a Url that you didn't have setup as a portal alias.  Those of you that have been around for a while no what I mean. For those that don't you can still see that this error is still a rather common one by searching google for "DotNetNuke Configuration Error"   Don't  be alarmed, most of those portals are probably working portals, but the efficient spiders of google have found ways to get to these 2.x portals by ways that were not setup.

It get's complicated
As with all maturing software that is trying to handle more and more use cases and feature requests, the code gets a lot more complicated.  Not only was this feature added in 3.0, but we also added search engine Friendly Urls.  Making all these work together drove the number of possible scenarios up pretty high, and as I was working on a bug that was keeping the portal alias wildcard feature from working correctly, I got pretty intimate with the code.  The only way I could get the wildcard feature to work reliably across DNN instances with multiple portals that each wanted to implement wildcards and hide the dotnetnuke configuration error if no alias could be matched at all was to redirect to the first alias of the default portal if all methods to figure out what actual portal was being requested were exhasted.  This actually adds another benefit though, and one that should really be available in any website, but that we hadn't really had in DNN. The benefit of looking up the first alias of the first portal is that you can put a url to whatever page you wish in there.  So if you were to put a Url in the first alias of something like domain.com/Custom404.htm then you could have a nicely formatted custom page/portal not found error. 

Why does my site redirect to localhost?
This is also what causes one of the most frequently asked questions on the forums, "Why does my site redirect to localhost?".  This is because most people will install DNN on localhost, then copy their DB and web files up to their server and try to access the site through a different Url.  I have a new fix for this though, which should really cut down on this common problem, and I hope to get it into 3.2.  The new fix is to check first to see if there is more than one portal, if not just let the default portal get all traffic that comes it's way. I know what you're saying. "Sheesh, why didn't that get included a long time ago".  Well, like I said it's complicated.

The details for those so inclined
Here are the steps that DNN uses to go about trying to find out which portal is being requested from the Url.  This takes place in the UrlRewrite HTTP Module (UrlRewiteModule.vb) in the OnBeginRequest sub which is a handler for the application.BeginRequest method and is basically the entry point for each and every request that gets handled by DNN.  These steps are for DNN 3.x portals.

  1. Get the Url that was used to access the site.
  2. Do some checks to make sure that the request is not a hacking attempt .
  3. check to see if it's actuall install.aspx that is being called, if so then exit since this is a global page.
  4. Apply the rules from SiteUrls.config (in the root of the DNN website). These  rules are used to Rewrite the Url into a friendly one.
  5. Get the TabId and/or the PortalId from the Url as either of these can be used to uniquely identify a particular portal. The TabId is also needed to go to the specific page being requested.
  6.  Look for an "alias" querystring value on the Url which can be used directly to look up the portal from the PortalAlias table.
  7. Get the DomainName portion of the Url, to be used if one of the other more specific methods (tabid, portalid, alias) can't locate the portal. This is the wildcard feature.
  8. If none of these produce a portal, then lookup the Host's default portal and use the first alias for a redirect.
  9. That is basically it, isn't that enough?

So there you have it. PortalAlias explained.  Feel free to ask questions in the comments.  I know I'll be sending people here now to learn more about how a little of the magic happens in DNN, so if there is anything to add lets make it happen.
    

10/9/2005 1:23:56 AM (Central Daylight Time, UTC-05:00)  #    Comments [16]
Tracked by:
"DotNetNuke Portal Alias explained" (DotNetNuke Secrets) [Trackback]
12/6/2005 5:16:37 AM (Central Standard Time, UTC-06:00)
So what should I do to escape the problem?
Direct editing table PortalAliases brings to an error Page couldn't be load
12/6/2005 8:24:31 AM (Central Standard Time, UTC-06:00)
If you make a direct edit in the PortalAlias table then you will need to restart the web app because this setting is cached.

You can restart the app by re-uploading a DLL to the \bin directory, or by updating the web.config file, or by re-starting IIS.
1/20/2006 1:13:41 PM (Central Standard Time, UTC-06:00)
I have a website setup running on //localhost/website/dotnetnuke which is connected to the LAN at work. If I try to open the site from another PC (my laptop in this case), using //TestingMachineName/website/dotnetnuke/default.aspx it fails to load the site. It gives the standard page cannot be displayed error message. I know i have the proper access to the folders, because I can browse to the //TestingMachineName/website/ directory and even open a website under another folder (that site was created using the starter kit from microsofts web developer tool).

The site is setup so all users can see everything on the site. I added a portal alias, but if I try to open that address from my laptop, it just gives me a page not found message. Do you have any ideas why I can't open the site from another machine?
1/20/2006 1:29:10 PM (Central Standard Time, UTC-06:00)
Are you adding those two starting slashes as part of the Alias for the portal?

If so, you don't want them. The alias should be TestingMachineName/website/dotnetnuke

1/20/2006 2:49:59 PM (Central Standard Time, UTC-06:00)
Thank you very much. It wasn't the // that was causing a problem, I just needed to put the additional subfolders after the machinename into my alias.
1/20/2006 3:12:04 PM (Central Standard Time, UTC-06:00)
OK, maybe I got happy too soon. The alias for the default portal works, but how do I get alternate portal aliases to work? I can't set it to the same name and just adding a machinename/website/dotnetnuke/newPortalName doesn't work?
1/20/2006 3:19:47 PM (Central Standard Time, UTC-06:00)
Yes, machinename/website/dotnetnuke/newPortalName will work if it was created as a child portal. There needs to be a physical folder under the dotnetnuke folder with the same name as the child portal. If that is not there, then there may be something wrong with permissions or it wasn't created as a child portal.
2/22/2007 6:18:31 PM (Central Standard Time, UTC-06:00)
Ive tried numerous times to upgrade to DNN 4.4.1. It even completes successfully and upgrades all the modules:
Upgrading DotNetNuke
Current Assembly Version: 04.04.01
Current Database Version: 04.00.02

00:00:11.812 - Upgrading to Version: 4.4.1 Success

However, every time I access the site I get "Firefox has detected that the server is redirecting" and tha page simply doesnt load. When I access /rss.aspx the data comes back correctly, and thus I believe the error must reside inside the Default.aspx. When Firefox failes it lands on: www.intdev.co.za/site/Default.aspx?alias=www.intdev.co.za/site. Why is it suddenly appending the Alias (even though this is a Parent portal) and howcome DNN gets caught in this endless redirect?

I can confirm having checked, adjusted and updated the PortalAlias table but with no luck. Can anybody advise?
3/14/2007 8:13:50 PM (Central Daylight Time, UTC-05:00)
Good article. However, I am having a problem moving my website from the live server to my local box. I backed up the files and did a SQL Server backup. I am using DNN 4.3.5

I made sure before the move that "localhost/funeralin" was in the PortalAlias table. I even deleted the virual directory "localhost/funeralin" and recreated it, bacuase I heard DDN caches this.

All I get in IE is a flashing status bar.

In firefox I get the error: "The page isn't redirecting properly"

Why does DNN do this? Where else is this cached, or stored to cause this behavior.

Can anyone help me with this?
10/4/2007 9:03:52 AM (Central Daylight Time, UTC-05:00)
If have the same issue with the never ending redirection after upgrading to the latest version (4.6.2).

Is there a way to fix this?
2/20/2008 10:36:03 AM (Central Standard Time, UTC-06:00)
I have version 4.08 running .I developed the site from dnn install package and transferred to new server.I updated portal alias.But it is redirecting indefinitely.Does anyone have solution ?
2/20/2008 10:42:41 AM (Central Standard Time, UTC-06:00)
Make sure you have restarted the application by re-uploading your web.config, or making a small change to it.
3/3/2008 7:16:37 AM (Central Standard Time, UTC-06:00)
How can make xxx.domain.com always redirect to www.domain.com?
dean
3/14/2008 2:36:04 PM (Central Daylight Time, UTC-05:00)
Website found waiting for a reply at the bottom right of my browser in IE in a continuous loop. Obviously following the steps illustrated and then redirecting at the last stemp to the localhost:85/Default.aspx (the alias that I included in the portal alias table).

Does anyone know how to solve this. I need to be able to debug on my local machine. Before I was just getting redirected to the localhost as that is the default behaviour.

Very Stuck here and I need a detailed response.

Jaime Weise
5/20/2008 5:56:50 PM (Central Daylight Time, UTC-05:00)
Hey guys, the problems gone away but I'd still like to know what caused it. Cheers.
6/26/2008 1:56:57 PM (Central Daylight Time, UTC-05:00)
John, I've got an old client on 3.2.2 that has come back wanting to add additional URLs to their list of portal aliases. On the new one's I've added (that aren't the first portal alias in the list) I'm getting the Firefox continuous redirect error. Is there a way I can make the site come up and more then one URL? I know that there are SEO issues with this, I'll fix those later, I currently need it to come up at multiple urls. Any help would be great.

BTW, this article is still great (after all these years). Reminded me of how 3.x used to work.

Dax
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):