<IfModule mod_ssl.c>
  <VirtualHost *:443>
          ServerAdmin cary@example.com
          ServerName example.com
          ServerAlias www.example.com
          DocumentRoot /var/www/wordpress
    DirectoryIndex index.php
    <Directory /var/www/wordpress/>
      AllowOverride All
      Order Deny,Allow
      Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Include /etc/letsencrypt/options-ssl-apache.conf
    Include /etc/letsencrypt/options-ssl-apache.conf
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
  </VirtualHost>
</IfModule>

<IfModule mod_ssl.c>
  <VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/wordpress
    DirectoryIndex index.php
    <Directory /var/www/wordpress/>
      AllowOverride All
      Order Deny,Allow
      Allow from all
    </Directory>
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =www.example.com [or]
    RewriteCond %{SERVER_NAME} =example.com
    RewriteRule ^ https://example.com%{REQUEST_URI} [END,NE,R=permanent]
  </VirtualHost>
</IfModule>