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

redirecting http to https without messing up qa-rewrite?

+5 votes
498 views
asked Jul 12, 2014 in Q2A Core by LaughingYoda
I trying to move my whole site over to https and have changed all links but, I'm having problems using .htaccess to redirect http to https, here's what I have in the file:
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]

2 Answers

–1 vote
answered Jul 16, 2016 by Varga Mark
this solution it is working :)
commented Jul 18, 2016 by Tibriz
No, its not. When you have the short link of the question, its not working like question2asnsfs.com/1798 so it tells you "redirects this url to question2asnsfs.com/index.php?qa-rewrite=1798" and 404 found error.
0 votes
answered Oct 8 by dr2050

Hey there, I was just mucking around with all different combinations -- I had the same problem as you -- and stumbled upon this one. The important thing is that the rule is above the other stuff (I think).

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

...