By BlackBelt35
Hello everyone. :) I’m a little puzzled right now. I’ve tried to setup a Virtual host for my subdomain “forum.mywebsite.com”. Because I need it for community software, as WordPress is already served by my main domain “mywebsite.com”.
So I’ve followed this tutorial : https://linuxize.com/post/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04/
Required folder is created in var/www, with the same name as the subdomain. (forum.mywebsite.com)
When needed, I’ve created a new conf file in etc/apache2/sites-available :
code<VirtualHost *:80>
ServerAdmin mywebsite@gmx.fr
ServerName forum.mywebsite.com
ServerAlias www.forum.mywebsite.com
DocumentRoot /var/www/forum.mywebsite.com
<Directory "/var/www/forum.mywebsite.com">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>
I think the setup is correctly done, but when I try to access the Public folder of my forum CMS with my browser, (forum.mywebsite.com/public), I got a redirection on my main WordPress page. The same when I just try to reach the root of my subdomain.
Apache2 rebooted and Virtual host enabled with a2ensite prompt.
DNS A record for subdomain is registered. (And actually works fine.)
Droplet was created with a Wordpress image already preinstalled.
So I wonder where is the potential issue ? Thanks ! :)
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!
Your rewrite logic for website.com (/var/www/.htaccess) is likely not checking if the actual subpage/subfolder you’re browsing (forum.website.com or even website.com/forum.website.com/public) is a real directory. So add this at the top of your mod_rewrite rules if you don’t have it:
RewriteCond %{REQUEST_FILENAME} !-d
This way WordPress doesn’t think it needs to send that request to index.php.
Cheers
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.