By preshu
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!
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!
Hello, @preshu
Have you tried to temporary remove or comment out the Rewrite rules in the first virtual host if they’re not needed?
RewriteCond %{SERVER_NAME} =www.blog.mydomain.com [OR]
RewriteCond %{SERVER_NAME} =blog.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Also are you using .htaccess files as well and if so can you share the content of both .htaccess files so we can check them?
Let me know how it goes.
Regards, Alex
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.