Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

how to redirect http to https in subdomain

+1 vote
54 views
asked Oct 10 in Q2A Core by fara

I have a q2a site in subdomain like http://subdomain.example.com.

I have ssl certificate enabled. How can I redirect links to https://subdomain.example.com  using .htaccess?

Thanks

Q2A version: 1.8

1 Answer

0 votes
answered Oct 10 by Donutlover
Try htaccess code-

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

Reference :
https://stackoverflow.com/a/27029144/4558437
commented Oct 10 by fara
Thank you for your answer.
So the .htaccess file https://github.com/q2a/question2answer/blob/dev/.htaccess should be like:

Options -Indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>

?
...