I cannot be able to redirect my http traffic to https so my site is reachable using both http and https but I want it only to be reachable via https. My .htaccess file located in /var/apps/web/ looks like this:
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]
I have edited apache2.conf and added the below config:
<Directory /var/mode/cci/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
My document root located in /etc/apache2/sites-available looks as below:
<VirtualHost *:7777>
        ServerAdmin webmaster@localhost
        ServerName mydomain.co/
        DocumentRoot /var/apps/web/
        Header always append X-Frame-Options SAMEORIGIN
        Header always set X-XSS-Protection "1; mode=block"
        Header always unset Server
        Header always set X-Content-Type-Options nosniff
        <Directory />
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
        </Directory>
        <Directory /var/apps/web/>
                LimitRequestBody 512000
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -Indexes -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        TraceEnable off
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName mydomain.co/
        DocumentRoot /var/apps/web/
        Header always append X-Frame-Options SAMEORIGIN
        Header always set X-XSS-Protection "1; mode=block"
        Header always unset Server
        Header always set X-Content-Type-Options nosniff
        <Directory />
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
 </Directory>
        <Directory /var/apps/web/>
                LimitRequestBody 512000
                Options -Indexes -FollowSymLinks -MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -Indexes -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
         SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.crt
        SSLCertificateKeyFile /etc/apache2/ssl/apache.key
        ErrorLog ${APACHE_LOG_DIR}/error.log
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
        TraceEnable off
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Kindly assist!
 
    