I see many similar questions written in gibberish that I don't understand:
- Redirecting non-www URL to www using .htaccess
- Redirecting URL without www to www
- Redirect Non-WWW to WWW URLs
- rewrite url to non www multiple sites
I'd like to know how to do this using Microsoft's technology ...or just explain to me what those others are talking about and how to use them.
Basically, if someone types "mydomain.com" into the address bar, I want it to resolve to "www.mydomain.com" when the page has finished loading.
EDIT: This is a hosted website, so I can't configure the IIS Server.
This is kind of a funny solution. I am only suggesting it because of the limitations which you described. It's better to do it in IIS or using an HTTP Module like those other answers are suggesting. However, this would also work, it's just not a very good way to accomplish it.
You can put this code into your Page Init Event handlers (or Init Handler for your master page).
Where
mydomain
is likemydomain.com
without thewww
.It checks to see if the URL doesn't have WWW where WWW "should" be. If it isn't there, redirects the user to a version of that page that has WWW in the correct spot.
Now add config tag in web.config
(or) Go with this one: