WILDCARD SUBDOMAIN HTTP REDIRECT TO HTTPS

Hi there,

I'm using the Multisite and wildcard, and I setup the SSL on my domain. I'm also set up .htaccess to let website can force SSL.

If I enter the http://domain.com, it will auto redirect to https://domain.com, but If I enter the http://subdomain.domain.com, it will auto redirect to https://domain.com.

How can I fixed it, let it can do that when I enter the http://subdomain.domain.com, then it will auto redirect to https://subdomain.domain.com??

My site: seobook.xyz, Test subdomain: seo.seobook.xyz

My .htaccess:

# BEGIN HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END HTTPS

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

  • James Morris
    • WordPress Enthusiast

    Hello leoventans,

    The correct rewrite rule to use in this situation is the following:

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

    This *should* redirect all requested domains pointed to that directory on your server to the https schema. If you have added the above to your .htaccess and it is still not working correctly, you may have a conflict in your .htaccess hierarchy.

    Could you please check to ensure there are no .htaccess files higher in the filesystem hierarchy that are performing any rewrites?

    Also, in order to help you better with your issue, would you please grant me access to your site?

    You can learn how to grant WPMU DEV Support Access at the following link:

    https://premium.wpmudev.org/manuals/wpmu-dev-dashboard-enabling-staff-login/

    Please reply back here once you've enabled access so I will be notified.

    Best regards,

    James Morris

  • James Morris
    • WordPress Enthusiast

    Hello leoventans,

    When I checked your seo subsite in Network Admin -> Sites -> Edit Site, I saw that your had the siteurl and home url set to the http protocol. This was causing the redirect issue you were experiencing. After changing these urls to the https protocol, the redirect is working properly now.

    Let us know if you have any further questions. We'll be happy to help! :slight_smile:

    Best regards,

    James Morris

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.