Answer the question
In order to leave comments, you need to log in
Apache how to properly set up a virtual host?
Hello The
following question:
A number of virtual hosts are now configured on Apache for second-level domains:
test.example.com:80
test2.example.com:80
test3.example.com:80
Now there is a task to make one more virtual host, for example demo.example. com but to which all other second-level domains that are not registered as separate virtual hosts will refer. I tried to do it through ServerAlias *.example.com , but then other hosts stop working. Those. opening test.example.com opens demo.example.com.
Can you tell me if it's realistic? And if it's real, how?
Answer the question
In order to leave comments, you need to log in
Order matters
<VirtualHost *:80>
DocumentRoot /var/www/test1
ServerName test1.site.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/test2
ServerName test2.site.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/test3
ServerName test3.site.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/tests
ServerAlias *.site.com
</VirtualHost>
Realistically
doing multiple
VirtualHost configurations *:80>
DocumentRoot "/var/www/demo.example.com"
ServerName test1.example.com
ServerAlias test1.example.com
Directory "/var/www/demo.example.com">
AllowOverride All
RewriteEngine On
Options Indexes FollowSymlinks
/Directory>
ErrorLog /var/www/site-error.log
LogLevel warn
/VirtualHost>
create new
VirtualHost config file *:80>
DocumentRoot "/var/www/demo.example.com"
ServerName test2.example .com
ServerAlias test2.example.com
Directory "/var/www/demo.example.com">
AllowOverride All Rewrite Engine
On
Options Indexes FollowSymlinks
/Directory>
ErrorLog /var/www/site-error.log
LogLevel warn
/VirtualHost> The
toaster does not allow you to write correctly, I hope you understand what you need to < put in some places
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question