There are VDS with three IP addresses. Interfaces are configured, everything works. It is required, by analogy with the 000-default.conf settings, to make settings for all IP addresses.

In 000-default.conf I redirect from the first IP to the first domain (everything works):

 <VirtualHost FIRST_IP_HERE:80> ServerAdmin name@example.com ServerName FIRST_IP_HERE Redirect 301 / http://FIRST_DOMAIN_HERE/ ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

I try by analogy to redirect from another IP to another domain, but redirection when accessing the second IP still goes to the domain from 000-default.conf .

I tried to copy the description of the virtual host in the file 000-default.conf (by changing the IP and domain), and to create the file 001-default.conf and make for it a2ensite . Nothing helps.

Can you please tell me if I can configure apache so that when I access FIRST_IP redirect to FIRST_DOMAIN , when I contact SECOND_IP , I redirect to SECOND_DOMAIN , etc., and if I can, how can I do it?

    1 answer 1

    Could not reproduce your problem. On the local machine, successfully redirected to different domains.

     <VirtualHost 127.0.0.10:80> ServerAdmin name@example.com ServerName 127.0.0.10 Redirect 301 / http://example.com/ ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> <VirtualHost 127.0.0.11:80> ServerAdmin name@example.com ServerName 127.0.0.11 Redirect 301 / http://example.net/ ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

    I think you should carefully read the vhosts documentation and see similar questions in English SO.

    • Thank you very much for your response! Indeed, now everything works. When I checked from work during the day, it did not work, but now it works from home in the version with several files, and in the version with one file 000-default.conf . - spopovru