Question
vhost is redirecting to another subdomain.
Hello Everyone,
I have a confusing issue configuring vhost in apache on Ubuntu 18.04.
I have this wordpress vhost config:
<VirtualHost *:80>
ServerAdmin mail@outlook.com
ServerName blog.mydomain.com
ServerAlias www.blog.mydomain.com
DocumentRoot /var/www/blog
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/blog/>
AllowOverride All
</Directory>
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.blog.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =blog.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
And then, I have a PHP app in another directory, the vhost config file is:
<VirtualHost *:80>
ServerAdmin mail@outlook.com
ServerName subdomain.mydomain.com
ServerAlias www.subdomain.mydomain.com
DocumentRoot /var/www/subdomain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/subdomain/>
AllowOverride All
</Directory>
</VirtualHost>
I Configured the DNS records. but subdomain.mydomain.com is redirecting me to blog.mydomain.com.
Is there a missconfiguration or something else? (I’m really noob on apache configurations, sorry if it’s stupid.)
Greetings, and stay safe!
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.
×