I have a secure wordpress website redirecting issue. I’ve researched this as thoroughly as I can, but can’t seem to figure it out. I have two conditions for redirecting traffic in the .htaccess file. The first, is that all http://www traffic needs to be redirected to https://afspa.org. This I’ve accomplished with the following:
#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://afspa.org/$1 [R=301,L]
</IfModule>
#END WordPress
My second condition is that all https://www traffic needs to also be redirected to https://afspa.org. However, when users type in or have bookmarked “https://www.afspa.org” they don’t get redirected. Instead they get a security warning. What am I doing wrong?
This is because your certificate is valid for
afspa.orgbut not forwww.afspa.org. The browser checks the certificate before redirecting.