: Need help getting 'www' working for domains and subdomains using Apache & DNS I've searched through a lot of different posts asking this question and I haven't really seen a straight forward
I've searched through a lot of different posts asking this question and I haven't really seen a straight forward answer on how to get this working.
At the moment, with the following settings, adding a www to the front of my domain or subdomain does not load the webpage, I get a redirection saying my domain can't be found.
Could someone explain how I can get domain.com and subdomain.domain.com to work?
Currently, I have the following DNS records:
EDIT: This is the DNS Records that worked AFTER closetnoc's answer
I did not have the CNAME's before
A @ 1.2.3.4
A subdomain 1.2.3.4
CNAME www domain.com.
CNAME subdomain subdomain.domain.com.
I also have a virtual host file as follows below, (and another one for the subdomain, but you get the gist). This is to force redirect to HTTPS:
<VirtualHost *:80>
RewriteEngine on
ReWriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) %{HTTP_HOST}/ [NC,R,L]
</VirtualHost>
<VirtualHost *:443>
ServerName domain.com
ServerAlias domain.com ServerAdmin webmaster@localhost
DocumentRoot /path/to/public_html
SSLEngine on
SSLCertificateFile /path/to/domain.crt
SSLCertificateKeyFile /path/to/domain.key
SSLCertificateChainFile /path/to/domain-bundle
<Directory "/path/to/public_html">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/domain-error.log
CustomLog ${APACHE_LOG_DIR}/domain-access.log combined
</VirtualHost>
More posts by @Martha676
1 Comments
Sorted by latest first Latest Oldest Best
Your DNS example is missing a few elements. Here is how I would set things up.
example.com A 10.0.11.101
www CNAME example.com
sub-domain CNAME example.com sub-domain CNAME example.com
If all are on a single web server, then the web server will take the request header and respond to the request accordingly.
In this case, only your parent domain needs an IP address. Remember, this is routing domain names to IP addresses only. As for the rest, CNAME is an alias that points to your domain name. So for example.com, sub-domain.example.com, and sub-domain.example.com, these will all use the IP address of example.com.
You will need a similar site set up for sub-domain.example.com and sub-domain.example.com as you do for example.com and example.com. Remember that sub-domains are separate sites from the parent and need to be set-up as a new site. If you want the sub-domain content to be served out of your parent domain, then that is a whole other question, but still requires the sub-domain site to be created.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.