H
H
hrvasiliy2015-06-23 18:51:58
PHP
hrvasiliy, 2015-06-23 18:51:58

How to set up "infinite" subdomains?

Once I needed the ability to create "endless" subdomains on the site, more precisely, so that each user could create an unlimited number of subdomains for himself, that is, in fact, it just looks like a subdomain, it is simply written to the database, then, when accessing this subdomain, the required information is displayed to the user. The whole thing was done on hosting, so I just asked, they set up such an opportunity for a specific domain.
Now, I'm trying to do the same, only on VDS.
What have I already done? I set up LAMP, created a couple of folders for two different sites, linked domains (site1.ru and site2.ru). I added an index.php file to each of them, the first contains a text output saying that this is site1.ru, the second, that this is site2.ru. Here's what's interesting, when I try to follow the link with a subdomain on the first site (sub.site1.ru) - everything is in order, as it should, it displays: "SITE1.RU", but when I go through the second site with a subdomain (sub.site2.ru) it also displays SITE1.RU, while passing without a subdomain (sub.site2.ru) it displays: "SITE2.RU". So I came to the conclusion that something needs to be configured here, I would only like to find out what exactly, okay if both sites did not work, so one works :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valery Ryaboshapko, 2015-06-23
@hrvasiliy

Use
ServerAlias ​​*.siteX.ru
in the VirtualHost section of each domain.

A
Andrey, 2015-06-23
@reaferon

Not the first time I meet on Habré

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question