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?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
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 insites-available/staging.rainierlaan-le.ssl.conf
the path was still/var/www/html
. I changed the path and didsudo service restart apache2
and it worked again. Hopefully this answers your question!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.
Regards, Bobby