HTTPS is working and HTTP is working, but when I try to add the redirect of HTTP to HTTPS in .htaccess file, it gets caught in a redirect loop.
Here is apache:
<VirtualHost *:80> DocumentRoot /var/www/html/mysite ServerName mysite.com ServerAlias www.mysite.com </VirtualHost> <VirtualHost *:443> DocumentRoot /var/www/html/mysite ServerName mysite.com ServerAlias www.mysite.com SSLEngine On SSLCertificateFile /var/SSLs/somecert.crt SSLCertificateKeyFile /var/SSLs/somekey.key SSLCACertificateFile /var/SSLs/trust.crt </VirtualHost> Here is .htaccess file:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / # RewriteCond %{ENV:HTTPS} !=on # RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress When I uncomment the RewriteCond, then it gets caught in a loop. In Wordpress I've set the site and home url to https.
I also added the following to the wp-config.php which solved https not working previously:
$_SERVER['HTTPS'] = 'on'; Appreciate any help. Note that I replaced the actual domain with mysite