@sierracircle What Apache version is the advice for? What Linux distro is this for? I tried this and got this error on a CentOS 7 running Server version: Apache/2.4.6 (CentOS)
and I got this error:
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
First of all, aren’t we supposed to be editing our Apache Config Files located in /etc/httpd/sites-available? not sites-enabled?
Secondly, is our example.com.conf supposed to look like this advice:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
DocumentRoot /var/www/example.com /public_html
ErrorLog /var/www/example.com /error.log
CustomLog /var/www/example.com /requests.log combined
</VirtualHost>
<Directory /var/www/yourwebfolder>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
This is my question. And lastly, isn’t yourwebfolder supposed to be called a document root? Or are they different? My last question is for Digital Ocean. Can we please get a qualified document that helps CentOS 7 customers make it so the same page with both www.example.com and example.com have good DNS but we want people who go to both pages only END UP on the example.com domain please? Thanks in advance.
Lets start with www,
DNS
you will want to add an A-record with just www in it for your domain.
this will make www go to your droplet.
Apache Config File
after that, you will want to add www as an Alias in your site config file, (if you are using Apache). This should be located in /etc/apache2/sites-enabled
find the section where it says:
and add this under it:
While you are there, make sure that you have a section that has this(replace yourwebfolder with whatever you use for your root web folder)
reload Apache and now you should be able to get to your site using either www.yourdomain.com or just yourdomain.com
.htaccess file
lastly, add this to your .htaccess file in your web folder:
that will at least take care of www. You can use the same idea for other other sub-domains.