Hi everyone!
I have vhost pointing to certain folder using the main domain and I’m setting up the second one, a subdomain, pointing to another folder. The first one works fine since forever, and the second one never worked, always returning 404. Funny thing is that if I call the IP address it loads the second vhost.
First vhost (working):
<VirtualHost *:80>
ServerAdmin fechagas.dev@gmail.com
ServerName cropflow.com.br
ServerAlias www.cropflow.com.br
DocumentRoot /var/www/html/cropflow
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =cropflow.com.br [OR]
RewriteCond %{SERVER_NAME} =www.cropflow.com.br
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Second vhos (return 404):
<VirtualHost *:80>
ServerAdmin fechagas.dev@gmail.com
ServerName api.cropflow.com.br
ServerAlias www.api.cropflow.com.br
DocumentRoot /var/www/html/cropflow-api/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =api.cropflow.com.br [OR]
RewriteCond %{SERVER_NAME} =www.api.cropflow.com.br
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Both vhosts was configured following this article: https://www.digitalocean.com/community/tutorials/como-configurar-apache-virtual-hosts-no-ubuntu-16-04-pt
Thanks in advance!
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.
what is the “public” in
DocumentRoot /var/www/html/cropflow-api/public
Are you sure it is in a public folder?
Also you could take out the redirect to https and test it on http only
Yes I thought it might be the cert. And yes I do have some advice, lets encyrpt doesnt support virtual hosts in one file, so just use the working one and copy the contents too a second conf file and then run the certbot again
this might help
https://community.letsencrypt.org/t/setting-up-letsencrypt-for-a-single-wordpress-multisite-installation-with-many-domains/46511/6
It did with me
Your api.cropflow.com.brvhost does a redirect to https://api.cropflow.com.br. So you’d need to look at the SSL/433 vhost and see if it’s properly configured.