Resolve domain without www

I did a lot of googling on this topic, and none of the answers seem to help. So, here we go.

Able to resolve:
www.shopgme.com

Unable to resolve:
shopgme.com --> hits default Apache index page.

I have 2 entries in /etc/apache2/sites-available, one for port 80, another for 443

I have also added 2 A records (in linode), one with www, and one blank… both with the same IP.

Even tried editing my /etc/hosts file to do the whole "private ip hostname.domain.com hostname", which didn't seem to help me either.

The blocks in my config files look like this:

/etc/apache2/sites-available/greymatter-store.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.

        ServerName www.shopgme.com
        ServerAlias shopgme.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf


RewriteEngine on
RewriteCond %{SERVER_NAME} =www.shopgme.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

/etc/apache2/sites-available/greymatter-store-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.

        ServerName www.shopgme.com
        ServerAlias shopgme.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf

        Alias /static /home/greymatter/greymatter-store/app/static
        <Directory /home/greymatter/greymatter-store/app/static>
                Require all granted
        </Directory>

        Alias /media /home/greymatter/greymatter-store/app/media
        <Directory /home/greymatter/greymatter-store/app/media>
                Require all granted
        </Directory>

        <Directory /home/greymatter/greymatter-store/app/greymatter>
                <Files wsgi.py>
                        Require all granted
                </Files>
        </Directory>

        WSGIScriptAlias / /home/greymatter/greymatter-store/app/greymatter/wsgi.py
        WSGIDaemonProcess greymatter-store python-path=/home/greymatter/greymatter-store/app/greymatter python-home=/home/greymatter/greymatter-store/venv       
        WSGIProcessGroup greymatter-store

SSLCertificateFile /etc/letsencrypt/live/www.shopgme.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.shopgme.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

What am I missing here? TIA

1 Reply

Update(solved):

After clearing my browser cache, I noticed I was getting the following error when trying to visit my domain, without the www:

error: ERR_CERT_COMMON_NAME_INVALID

So, I ran certbot, again, which prompted me to generate new certs for both www.domain.com and domain.com. Doing this, then restarting apache seemed to solve my issue.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct