Make a root.aspx and put it in the root of your site. In IIS 7 manager make it to be on top of the list in Default Documents. Put this code in code behind file in PageLoad method: Code: string strServerName = Request.ServerVariables["SERVER_NAME"].ToString(); if (strServerName == "subdomain.domain.com") { Response.Redirect("http://www.domain.com/subdomainfolder/example.aspx", true); } else if (strServerName == "anotherdomain.com") { // ... you know the rest // ... Subdomain redirection is working for "http://subdomain..." but now does not work with "www.subdomain..." Feel free to make suggestions. ---------- givlupieomjpdy
Did you define the subdomain within your Site Info Manager? Under the Site Info Manager/Subdomain you still will need to define www.subdomain.domain.com as well as defining subdomain.domain.com.
Yes. But ... ... I already added www.subdomain.domain.com and subdomain.domain.com to the ... https://cp.Winhost.com/domains/dns.aspx https://cp.Winhost.com/sites/subdomain.aspx Do I need to wait for TTL timers to refresh DNS records? ------------------ | givlupieomjpdy |
So this is updated code for root redirect: Code: string strServerName = Request.ServerVariables["SERVER_NAME"].ToString(); if (strServerName == "subdomain.domain.com" || strServerName == "www.subdomain.domain.com") { Response.Redirect("http://www.domain.com/subdomainfolder/example.aspx", true); } else if (strServerName == "anotherdomain.com" || strServerName == "www.anotherdomain.com") { // ... you know the rest // ... "Subdomains and Domains mapping (redirect) to subfolders" done.
I have attempted this using URL rewrite (although not sure if it will work as my NS servers are not up to date); this is what I have come up with. The URLs currently look as follows (migrating hosts): http://jonathan.dickinsons.co.za/blog/... Create a subfolder for your subdomain, (not application). Add a new rewrite rule to it. Precondition: .* (Regex) Condition: {URL} matches the pattern .*://jonathan\.dickinsons\.co\.za(.*)? (Regex) Rewrite to: jonathan/{C:1} Append query string: don't. Any further ideas/corrections?
First you should make sure that jonathan.dickinsons.co.za resolves to the Winhost web server. If you ping jonathan.dickinsons.co.za you will see that it is not even resolving to Winhost. At this point the URL Rewrite/Redirect rule will not even work since jonathan.dickinsons.co.za is not pointing to Winhost.
- as I said that's the theory. I have to wait for the NS servers to transfer from my old host before I can test anything out.
Then try to set the A record for jonathan.dickinsons.co.za to point to IP address 96.31.35.44. Otherwise we really can't test if the URL Rewrite rule is working correctly.