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

I need .htaccess file to force https

+4 votes
254 views
asked Apr 24 in Q2A Core by Aras Ahmed
I installed ssl certificate

I need to make the traffic force https by modifying  .htaccess 301 or 302 redirect

Please provide me suitable solution
Q2A version: 1.7.4

3 Answers

0 votes
answered Apr 24 by Hypo
You can use cloudflare pages rules
commented Apr 25 by Aras Ahmed
I did try it the website go offline
Am I have to remove the .htaccess file while enable the cloudflare redirect ?
I am using comodo SSL can I use cloudflare with it ?
+1 vote
answered May 8 by Luis74
Modify from your control panel of your hosting the necessary parameters
You do not need to change .htaccess
+1 vote
answered May 17 by bluegenel
Put this at the very top of your htaccess file: This is what I use on my website.

If you don't get 'secure' in the address field in your browser it will probably be because you need to make all url's relative and not absolute.

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
commented Aug 6 by Hando Kroon
Just to confirm, is that how my htaccess file should look like then:

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


DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
Header set Access-Control-Allow-Origin "*"
#RewriteCond %{REQUEST_URI} !^/files/.*$
RewriteRule ^(files)($|/) - [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>
...