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

admin2025-01-07  3

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

main already had an ssl certificate working.

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

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

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

http blog.main was still working.

https blog.main was redirecting to https main

So the blog needs more work.

I changed the wordpress site-url and site-address of the blog to ''.

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 still redirects to https main.

http blog.main also redirects to https main.

(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 is also redirecting the main.

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

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.

Share Improve this question edited Jul 27, 2017 at 19:49 Dan1ell asked Jul 27, 2017 at 18:23 Dan1ellDan1ell 1013 bronze badges 1
  • I got the same problem in siteground with lets encrypting. For me the solution was leave the wildcard.. and make SSL for each domain or sub domain – ccdiego5 Commented Jul 7, 2019 at 17:54
Add a comment  | 

2 Answers 2

Reset to default 0

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]

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736253043a94.html

最新回复(0)