5

Is there any way to create subdomains via code and route them to my main domain?

product123.domain.com instead of www.domain.com/products/?id=123

1

1 Answer 1

8

We do the same thing, but do not generate the DNS records with code. Instead we create a wildcard DNS entry, resolving all subdomains to a given IP. Inside code, we retreive the subdomain from the request URI and use it for further processing.

We use Route53 DNS by amazon, and have an A entry like this

*.ourblogsite.com 184.5.5.5

Which resolves all subdomains to that IP address. Inside IIS we bind an application to port 80 of that IP rather than hostname, which will handle any requests. The Web application is an MVC application, which breaks apart the request URI and fishes the subdomain portion out. We use this to power the somename.ourblogsite.com functionality, where somename is a unique identifier given by the client.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.