R
R
rinaz222022-01-21 18:39:52
Apache HTTP Server
rinaz22, 2022-01-21 18:39:52

How to make autosubdomains in Apache?

I want to set up autosubdomains for my site, but something doesn't work.
There is a directory where all other sites are stored in their respective directories. For example, there is a main directory main and a directory with the site site1 (site.ru/main/site1).
It is necessary that when opening a site at the address: site1.site.ru, that site (site.ru/main/site1) opens.

Specified the following parameters for the domain:

<VirtualHost *:80>
    ServerName site.ru
    DocumentRoot /var/www/site.ru
</VirtualHost>

<VirtualHost *:80>
    ServerName site.ru
    ServerAlias *.site.ru

    UseCanonicalName Off
    VirtualDocumentRoot /var/www/user1/site.ru/main/%-4
</VirtualHost>


Working with Ubuntu

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alfieros, 2022-01-21
@mrsexy

As far as I can remember does not change

<VirtualHost *:80>
    ServerName site.ru
    ServerAlias *.site.ru
    DocumentRoot /var/www/site.ru
</VirtualHost>

Next, in the main directory where the folder with the site.ru domain is stored, create a subdomain folder of the site1.site.ru type.
But this is not accurate, try it)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question