0

I want to use the same exact ServerName, but load the first virtualhost block that works.

Here's how it should work:

If there is a wordpress folder in /var/www load that. Otherwise, load index.html in the /var/www directory.

Here is my config file with the 2 virtualhost blocks how I thought that would work. But it only works if I remove one or the other.

<VirtualHost *:80>
    DirectoryIndex index.php index.html
    DocumentRoot /var/www/wordpress
    ServerAdmin [email protected]
    ServerName devsite.test

    <Directory "/var/www/wordpress">
        Options FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined
</VirtualHost>

<VirtualHost *:80>
    DirectoryIndex index.php index.html
    DocumentRoot /var/www
    ServerAdmin [email protected]
    ServerName devsite.test

    <Directory "/var/www">
        Options FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog /var/log/apache2/error.log
    CustomLog /var/log/apache2/access.log combined
</VirtualHost>

Thanks!

6
  • The admin should be making this decision, not the web server. Commented Jun 1, 2019 at 22:04
  • Hi, I'm the admin this is for my VM that I develop and test on. Any ideas? Commented Jun 1, 2019 at 22:05
  • Change the configuration when you need to change it? use virtual machines and configuration management? Commented Jun 1, 2019 at 22:11
  • I guess I have to separate them into different URL's. Access my WordPress through devsite.test/wordpress and access a basic "load an index file" page on /var/www. Was hoping I could have it load from the wordpress if it exists. Thanks! Commented Jun 1, 2019 at 22:17
  • 2
    You have to separate with either ip or port, above thing will not work, virtual hosting work with port based, ip based or name based(DNS) you are not using any one of them. Let us know if you have some way to separate. Commented Jun 2, 2019 at 5:35

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.