1

I'm using Craft CMS 3 multisite installation with more than 20 website based on subdomains. There are websites:

website.com
one.website.com
two.website.com

with identical url paths but different content. I need to redirect each website from http to https. Root website htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
    RewriteRule (.+) index.php?p=$1 [QSA,L]

    RewriteCond %{HTTP:X-Forwarded-Proto} !=https
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

</IfModule>

But this adds index.php to URL while redirects. So http://one.website.com/test become into https://one.website.com/index.php?p=test

1

move these lines

 RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]

to the end of the file

| improve this answer | |
  • it works but it doesn't helps to redirect subdomains to its https versions. I guess there are should be some wildcard in RewriteCond row to redirect all subdomains. – Nikolay Bronskiy Jan 31 '19 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.