site on subdomain is redirecting to main site after installing wildcard ssl cert on both

I have a wordpress site on main.com and a second one on blog.main.com

main.com already had an ssl certificate working.

In cPanel I installed a new wildcard ssl certificate intended for '*.main.com'

(sorry, apparently i don't have enough reputation to post more than 2 links)

At this point: https main.com was continuing to function properly.

http blog.main.com was still working.

https blog.main.com was redirecting to https main.com

So the blog needs more work.

I changed the wordpress site-url and site-address of the blog to 'https://blog.main.com'.

And I changed the .htaccess of the blog and added 3 lines on top:

RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# BEGIN WordPress
IfModule mod_rewrite.c
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
/IfModule
# END WordPress

Now: https blog.main.com still redirects to https main.com.

http blog.main.com also redirects to https main.com.

(Changing the site-url and address and the .htaccess back, doesn't reverse the redirect.)

The only redirect in cPanel is 403 for '.(htaccess|htpasswd|errordocs|logs)$'

edit: Note that mail.main.com is also redirecting the main.com.

What could be causing the blog to redirect to the main site.

Topic ssl Wordpress

Category Web


I'll leave this question up in case it helps someone. But the answer turns out to be that the certificate wasn't installed on the subdomain.

When checking for a certificate with the ssl checker on https://decoder.link/sslchecker, it looked like it was installed on both main and the subdomain. (Tech support showed me this, so I didn't doubt it. I looked for the problem everywhere but there.)

Turns out, the redirection was causing the certificate to be shown for the subdomain. The certificate was only installed on the main site. (A different tech support person pointed this out.)

Not mad at anybody. Both techs were great and helped me plenty. This was just a small oversight.

Maybe this helps somebody.


Change your first 3 lines of your .htaccess to the follow. the code needs to go into the apache IfModule mod_rewrite

<IfModule mod_rewrite.c>
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.