We just experienced this on the dnncommunity.org website. Basically, we installed under one URL, upgraded a couple of times, then added a new URL as primary and the original URL was still being used. From what I could tell, the first URL in the database was being used, despite a different domain name being specified as IsPrimary and Site Alias Mapping Mode being set to Redirect.
IMPORTANT: If this is indeed a bug, it could have massive impacts on the ecosystem. Websites may be incorrectly serving out the wrong domain names and the website owners may not have any clue that it's happening.
List the steps to reproduce the behavior:
Originally, it was redirecting to the correct primary URL, but a lot of time, it doesn't.
The primary URL should be used when the setting exists and a HTTP 301 redirect should be performed is Redirect is the mapping mode.
We managed to fix this by deleting the original primary alias (that was no longer primary) and adding it to the end.

Do you have a portalSetting value for DefaultPortalAlias
D'oh! That nasty little bugger. Yes, and now it's changed. Shouldn't that get updated if the default portal alias is updated?
Yes it should, but was curious to see if that plays in. Honestly I think that setting can just go away
I'd agree with that. I don't recall why that separate setting was added to begin with... Isn't it legacy before the IsPrimary column was added to the PortalAlias table?
Yup. It dates back to 3.x
Makes sense.... I vote to put it on "the chopping block" :D
AFAIK, PortalDefaultAliasis not used for UrlFormat = "Advanced"
So do we mark the property deprecated in 9.4.1 and remove this in 11 ?
do we still support other UrlFormats?
I think it still works, but I would not see any reason to not use Advanced
@valadas,
In general, sites should use AdvancedURLs, but I'm having a big client with a large site, containing thousands of DNN pages with offers and they are using the tabid in the url to navigate the client on the phone and therefore using not even humanfriendly URLs.
@sleupold , @mitchelsellers , @daguiler , @valadas
Please help me to understand why portalalias is working well but when adding new language and enable content localization it starts redirecting to Primary alias whether mode is canonical or none
Is this not a bug or what am I missing here?
Or are there other settings need to be set when enabling content localization after adding a language?
Reported issue is #3017

@leedavi
the last one should be marked as primary as well. Login using the other alias and edit the French one to be primary.
Sorry,, I got disturbed and missed the description. The problem is I cannot change it. I had to do it form the DB.
I thought it might be related to this issue, but I see now this issue is closed.
@leedavi
you cannot edit the alias, you are currently using
you should be able to edit it while browsing using another alias (en-GB)
Ok thx Seb, you're right it could be linked to that. There was issues about missing portal alias, which caused this situation. Best we let this one rest until I re-create the issue with proof. The portal alias stuff is always a little odd in DNN9.
@hismightiness are you sure this was fixed? I have the same issue on an installation. I deleted the default alias in portalsettings (which was set to an old non existing alias) and the portal still serves both the www and non www alias, while being in redirect mode.
If I look at the code, I don't see how you could get a redirect if you delete the default alias from the PortalSettings table.
@Timo-Breumelhof Not that I'm aware of.
Many hosting control panels have a built-in feature to redirect www versions, could this be the case?
The PortalAlias functionality is very weak in DNN. It works, but is awkward to get your head around and often goes wrong. PortalAlias is the first thing to check when things do not point to the right place, And more often than not I fix it in the DB. It's difficult to pin down problems with the UI, but I certainly wouldn't be surprised if there is more than 1 bug, in certain situations when multiple langauges are used.
Is there any definitive documentation on how the portal alias should be setup for multiple languages and multiple urls?
Many hosting control panels have a built-in feature to redirect www versions, could this be the case?
No, this is on a pure windows server, no CP involved.
I "fixed" it by removing the portalalias and re-adding it
Ok, DNN seems to have lost the redirect again, I now resolved to adding a redirect in web.config, but there's definitely something wrong here.
FYI I also noticed this on the Evoq installation of a client
@skamphuis this one
@valadas we have been able to reproduce the issue on a local installation and we think we found a fix for it.
Thanks. I'll be trying to do some more testing and submit a pull request this friday.
@Timo-Breumelhof @skamphuis when you say a fix, do you mean something environmental or something Dnn related, should we reopen this and expect a Dnn related PR to come in?
DNN related. I'll ping you when we have a PR.
@Timo-Breumelhof @skamphuis when you say a fix, do you mean something environmental or something Dnn related, should we reopen this and expect a Dnn related PR to come in?
I have the changes in my fork, here.
I didn't get to do much testing yet, which is why I didn't submit a PR yet.
@valadas I have submitted PR #3832 . Please let me know if there's anything I need to do.