Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.3k views
in Plugins by
Q2A version: 1.6.3

1 Answer

+2 votes
by
I had to implement mine using a rewrite rule in .htaccess file. You can force it for certain pages here as well but its much easier to just force https for whole site. Some people will tell you not to do that because of the encryption overhead but I haven't seen any negative impact in doing this.
by
Thank you Richard. How would it look like in htaccess? I tried these lines and other combinations like
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

but it didn't work.
by
edited by
Hi Arlo,

Here's a copy of my .htaccess file. Lines 4 & 5, the rewrite condition and rule, are what you need.
You may also want to change your site_url in qa_options table from http://www.yoursite.com to https://www.yoursite.com

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=302,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>
by
Thanks, Richard

I tried those lines and also changed the url in the database table and when I refreshed the site, it wouldn't load back up at all. Said it had a loop...

So I kept looking and found these 3 lines that were able to work. However, the lock in the SSL shows a yellow triangle instead of a green lock.

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} yourfolder
RewriteRule ^(.*)$ https://yoursite.com/yourfolder/$1 [R=301,L]
by
Oh i got it to work!!!

I just needed to change the image (logo) external link which was being called from the admin panel with a "http" to "https" and it works! SSL is all green at the top now!

Thank you, Richard! I appreciate it.
by
Hi guys, I'm hoping you can help me I'm trying to redirect whole site to https but, having problems, here's my code

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#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]

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

</IfModule>

I have tried adding your codes but, i think it gets messed up because of the www. redirect. Any help would be great, thanks
by
figured it out myself

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On

#RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourwebsite.com/$1 [R=301,L]

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>
...