0

I created a virtual host for a domain abc.com to point to the directory /var/www/abc.

So in my sites-enabled I had this:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName abc.com
    DocumentRoot /var/www/abc
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =abc.com [OR]
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

But now I wanted to change it to another directory xyz. So I ran a2dissite en created a new virtulhost which now looks like this:

<VirtualHost *:80>
        ServerAdmin admin@example.com
        ServerName abc.com
        DocumentRoot /var/www/xyz
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =abc.com [OR]
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>

I have restarted apache. But when I access abc.com it still opens the website in /var/www/abc.

I cleared browser cache and cookies...

Is there any other place where I have to make changes?

  • Have you reloaded apache after changing the configuration files? Both VirtualHosts only apply to http/80 traffic but both redirect to https/443, have you changed the VirtualHost configuration for https/443? – Torin Apr 12 at 15:04
  • 1
    Check which site is enabled (ls -la /etc/apache2/sites-enabled/) and check what your default DocumentRoot points to. – Freddy Apr 12 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.