I am a web application developer, just a beginner. I am designing a small J2EE web application (for example, the service name would be like http://www.example.com). It uses Apache Tomcat. Spec: When a user sign up into the web application, he will get a custom domain like
http://username.example.com
How can i accomplish this in my web application. I am still developing the app. i have not hosted it yet.
You’ll need to create a virtual host for each subdomain in Apache configuration like:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/subdomain1.example.com
ServerName subdomain1.example.com
ErrorLog logs/subdomain1.example.com-host.example.com-error_log
CustomLog logs/subdomain1.example.com-access_log common
</VirtualHost>
There is one problem though. If your solution requires folders creation, virtual host addition and apache restarts which does not look good to me. How would I deal with this problem is:
If you use this way, you only need to setup the above once and then add the subdomains in to the storage which appears to be more flexible solution than creating subfolders and modifying Apache configuration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With