Answer the question
In order to leave comments, you need to log in
How to correctly configure redirection of all requests for any subdomain name to the appropriate folders on the apache2 web server?
Greetings,
I tried different variations of the settings, I came to this look.
Dns set up, added the *.mydomain.ru subdomain.
But subdomains stubbornly do not refer to folders ... I searched for errors in the Apache logs - nothing.
Maybe this is an old version and the second Apache does not understand this code?
<virtualhost *:80>
ServerName www.my_domain.ru *.my_domain.ru
ServerAlias my_domain.ru www.my_domain.ru
ServerSignature Off
RewriteEngine on
RewriteCond %{HTTP_HOST} ^my_domain\.ru [NC]
RewriteRule ^/(.*) http://www.my_domain.ru/$1 [L,R]
VirtualDocumentRoot /var/%1
ErrorLog /var/log/my_domain.ru/error.log
CustomLog /var/log/my_domain.ru/access.log combined
ServerSignature On
Options FollowSymLinks Includes MultiViews ExecCGI
UseCanonicalName Off
</virtualhost>
Answer the question
In order to leave comments, you need to log in
I just checked and it worked right away.
Apache config:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /www/testdomain
ServerName www.testdomain.local
ServerAlias *.testdomain.local
VirtualDocumentRoot "/www/testdomain/%1"
</VirtualHost>
most importantly I don't see any request error in the logs.. tried in different browsers the result is the same so it's not a cache.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question