Question
404 Not found when trying to add subdomain
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 "rainierlaan.nl"
works perfectly fine. Now I want to add a subdomain "staging.rainierlaan.nl"
but it returns a 404 Not found. What am I doing wrong?
First, these are my DNS records. I added *.rainierlaan.nl
with the right IP-address (See below)
I went on the server and added staging.rainierlaan.nl
within /etc/apache2/sites-available
with the following:
<VirtualHost *:80>
ServerName staging.rainierlaan.nl
ServerAlias www.staging.rainierlaan.nl
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} =www.staging.rainierlaan.nl [OR]
RewriteCond %{SERVER_NAME} =staging.rainierlaan.nl
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
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:
Error.log
[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.
×