My Subdomain will redirect back to the main site. How do I fix this so it redirects to the subdomain? My main site is a WordPress adult site so I'll use example.com to explain. All I have in the subdomain directory is an index.php file with phpinfo().
I have a website at www.example.com. I set up a Virtual host file in /etc/apache2/sites-available and did the command: a2ensite example.com.conf. Then I restarted apache2.
<VirtualHost *:80> # Admin email, Server Name (domain name), and any aliases ServerAdmin email@example.com ServerName subdomain.example.com ServerAlias www.subdomain.example.com Redirect / https://subdomain.example.com # Index file and Document Root (where the public files are located) DirectoryIndex index.php index.html DocumentRoot /var/www/subdomain # Log file locations LogLevel warn ErrorLog /var/www/subdomain/log/error.log CustomLog /var/www/subdomain/log/access.log combined <Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from localhost </Location> </VirtualHost>
In DNS tab on Cloudflare, I have an AAAA record and an A record with Subdomain in the name field and the server IP address in the value field. I have entries for the subdomain and also www.subdomain.