How to enable wildcard subdomains?

Artashes

Administrator
Staff member
One of my projects requires setting the "subdomain resolution" to a "wildcard" setting.

This makes it so whatever subdomain a visitor puts in (i.e. test.example.com) it resolves back to the main domain name example.com

" *.example.com " redirects to -> " example.com "

In more technical terms (according to programmer) I need to add "ServerAlias *.example.com" to the httpd.conf file (but that to me is like Chinese to a Ukrainian).


Any idea on how to make this work? Where and how it can be accomplished?

Thank you.
 
You are on the right path with httpd.conf
What you would do is
<VirtualHost 107.***.**.**>
DocumentRoot /home/domain.net/public_html
User username
Group usergroupname
ServerAlias *.domain.net
ServerName www.domain.net
RedirectMatch 301 (.*) http://domain.net$1
</VirtualHost>
Let me know how it works. :)

---edit---
forgot about bind
in your cp dns entries you want to forward the subdomain to an ip
*.domain.net. 14400 IN A 107.***.**.**
remember to fill in your normal ip :thumbsup:

--edit again lol--
service named restart
service httpd restart
 
Last edited:
Back
Top