Programmatically create subdomains with apache and spring

I am developing an application using Spring, jsp and Apache 7.0 server, now suppose I have a register domain such as "www.example.com" and in my application the user fills out a registration form in which the user is requested to enter his url to name such โ€œ123โ€ as soon as it submits the form after filling in the details, I want to redirect it to the newly created URL in our case โ€œ123.example.comโ€

Now in this movement I need to create a subdomain in my code before it is redirected. I went through Google to not find much.

Any help

Thanks in advance.

+6
source share
2 answers

You can use the wildcard cname (i.e. * .example.com), then use the spring interceptor ( http://java.dzone.com/articles/using-spring-interceptors-your ) to determine which subdomain is being requested by the user.

+1
source

You need to enable wildcard subdomains. This will allow your application to respond to requests from anything.yourdomain.com. Then your application needs to define a route that converts the subdomain into a variable so that you can use it to span database queries in your account. After the user installs his custom subdomain, they must register their domain under their account (so that you can search for an account by domain instead of a subdomain), then create a DNS CNAME record that points to their subdomain. These principles apply regardless of language / structure.

0
source

Source: https://habr.com/ru/post/950167/


All Articles