404 Not found when trying to add subdomain

Posted January 30, 2021 564 views
UbuntuApacheLaravelDigitalOcean Droplets

I have a simple domain and want to add a subdomain to it for staging purposes. I have a droplet where I installed Apache and the regular domain "" works perfectly fine. Now I want to add a subdomain "" but it returns a 404 Not found. What am I doing wrong?

First, these are my DNS records. I added * with the right IP-address (See below)

I went on the server and added within /etc/apache2/sites-available with the following:

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/website_staging

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

I’ve followed this tutorial to add a SSL certificate to that domain

And that all went fine but it said something already exists. I also followed this tutorial to add the domain.

I restarted apache using sudo systemctl restart apache but whenever I try to reach that domain it says 404 not found.

When I ping the domain it returns the right IP address and error.log return the following:


[Sat Jan 30 22:17:13.320880 2021] [mpm_prefork:notice] [pid 83354] AH00169: caught SIGTERM, shutting down
[Sat Jan 30 22:17:13.512393 2021] [mpm_prefork:notice] [pid 83632] AH00163: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sat Jan 30 22:17:13.512501 2021] [core:notice] [pid 83632] AH00094: Command line: '/usr/sbin/apache2'

What am I doing wrong? Am I missing something?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Sure @bobbyiliev I didn’t know my question went through. The actual solution had something to do with the SSL document root path not being synchronised with the regular path. The path in sites-available/staging.rainierlaan.conf was /var/www/website_staging while in sites-available/staging.rainierlaan-le.ssl.conf the path was still /var/www/html. I changed the path and did sudo service restart apache2 and it worked again. Hopefully this answers your question!

  • Hi there,

    Ah yes, the SSL virtual hosts update would indeed explain the problem!

    Happy to see that the site is working and thank you for sharing the solution here with the community!


Hi there @Rainierlaan,

I can see that your staging website is already working as expected. Would you mind sharing with the community how you got this working?

Usually, this could be due to file permissions. If Apache does not have read access to the document root of your website it might fail to load the files from there.