Question
Virtual host returning 404
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.
×