Multi-subdomain and CNAME redirect not working properly

tomich20

New member
Joined
Apr 25, 2021
Messages
2
I have a VPS with 1 shared IP for multiple sites. For one of my projects (myAwesomeSite.com), i want all my users to:
  1. Have their own subdomain pointing to the main site. example: jhon.myAwesomeSite.com, denise.myAwesomeSite.com
  2. Have their own external domain pointing to the main site. example: sales.jhonsExternalSite.com, deniseExternalSite.co.uk

For case 1, i added an A record to myAwesomeSite.com pointing to my servers IP, and modified httpd.conf adding: "ServerAlias *.myAwesomeSite.com"

NameTTLTypeValue
*3600A1.2.3.4

Everything seems to work great, any subdomain i try gets redirected to the main site (keeping the url, so i can process it with PHP). ?

For testing case 2, at the same server i have another domain: jhonsExternalSite.com, so i added in the domains DNS config the following CNAME:

NameTTLTypeValue
sales.jhonsExternalSite.com.3600CNAMEjhon.myAwesomeSite.com.

It seems to get redirected, because i get the site "Apache is functioning normally", :confused: but im not getting myAwesomeSite.com. Am i missing something? both domains are at the same server (sharing IP), but i need to make this work for other domains inside and outside my server. Also it would be great to continue using wildcards so i dont need to create rules for each user.

thanks in advance!
 
ok, the problem is that the "ServerAlias *.myAwesomeSite.com accepts any subdomain, and does not redirect to the correct virtual host.
Adding another server alis for the specific client works. so the final httpConf looks like this:

<VirtualHost 1.2.3.4:80 >
ServerAlias sales.jhonsExternalSite.com
ServerAlias *.myAwesomeSite.com
......

<VirtualHost 1.2.3.4:443 >
ServerAlias sales.jhonsExternalSite.com
ServerAlias *.myAwesomeSite.com
......

the thing is that i dont want to add a specific line for each client (they are thousands). Anything i could do to correct it?
 
Back
Top