I have a domain name: TestSite.com. I create several subdomains for this site and refer to them as first.TestSite.com, second.TestSite.com, etc.
How do I refer to TestSi
Since you tagged your question ASP.NET, I'm going to assume you want to do this server-side, so you are not relying on JavaScript on the client-side to generate HTML links.
First of all, make sure you have a web.config file in your subdomain sites, and add this to the configuration:
Using this setting in your ASPX pages, hyperlinks on one of your subdomains' pages would look like this:
Go to main domain home page
Go to products page on the main domain
The setting with name="MainDomain"
will be read from the configuration file, and inserted into the page where it says <%$ AppSettings: MainDomain %>
. This way, you are creating the required HTML on the server-side, with no hard-coding required.
If you need to change the name, simply update the configuration file, and all pages will automatically use the new domain name.