Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
930 views
in Q2A Core by
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
by
this solution it is working :)
by
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
by

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>

...