Proper Way to Redirect to HTTPS - https

According to the tool below, I'm not redirecting our site to HTTPS properly.
https://www.linksspy.com/seo-tools/free-seo-ssl-scan/barefootmosquito-com
Does anyone know the proper way to 301 redirect all versions of a homepage to https://www.example.com? These are the other versions of a homepage I'm referring to:
http://example.com
http://www.example.com
https://example.com?
I found this question asked a few years ago, but there was a lot of back and forth about what the best way to do this was, and there didn't seem to be a definite answer among the group.
Any help would be much appreciated. Thank you in advance!

To redirect your http non-secure traffic over the https secure page, you need to add below code into your .htaccess file. Once you update your .htaccess file then http, www and non-www all requests use the 301 permanent redirection tool and redirect on https secure protocol.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

You should use below code for 301 redirection, it will definitely work for you.
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.domainname.com%{REQUEST_URI} [L,R=301]

Related

Htacces rewrite for magento http to https for one domain of multishop

We are looking for a solution for our htacces rewrite and have been looking all over the internet and could not find the solution. We have a multishop with 10 shops and are now going over at https and first want to test one shop and then do the others. We have set everything up correctly, but do not get the 301 redirect to work.
We have tried the following code:
RewriteCond %{HTTP_HOST} ^domain\.be$ [OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.be/$1 [R=301,L]
But with this code all pages of the other webshops will also be redirected to this domain. Can someone help us setting it up so we can start transfer to https?
You need to remove the OR.
RewriteCond %{HTTP_HOST} ^domain\.be$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.be/$1 [R=301,L]
If you have split each of your domains to have independent vhosts (likely) and therefore utilize a separate block for SSL and HTTP, you should think about using a Redirect 301 in the HTTP section of the vhost to reduce complexity.

mod_rewrite redirect one domain to another URL

I have the freemagickey.com and the gogomagickey.com domains both pointing to the same Apache server. Any request to the gogomagickey.com domain should currently redirect to http://www.indiegogo.com/magickey-perfect-password-management/.
I have been reading the mod_rewrite docs and looking at what seems to be similar questions on SO and hacking away at my .htaccess with no joy. Either nothing is redirected or both domains are redirected.
Is it possible to do what need with mod_rewrite in .htaccess?
Yes, it's possible, and I believe this should do the trick for you:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} gogomagickey\.com$ [NC]
RewriteRule ^(.*)$ http://www.indiegogo.com/magickey-perfect-password-management/ [L,R=301]
</IfModule>

force https to a certain url

I know this issue has been addressed in many ways, but couldn't find any similar to this one I have now. The thing is that I have a code to force https to a certain or a particular url, but it seems that the (s) letter can be removed by hand so the url goes with http instead!! I mean I want the https to be force again in case the url is changed from https to http.
I hope it is a clear explanation.
RewriteCond %{SERVER_PORT} 443
RewriteCond %{REQUEST_URI} main
RewriteRule ^(.*)$ https://www.domain.com/folder1/folder2/login$1 [R,L]
does this code redirect again in case https is changed??
Thanks
Update #1
I got the meaning of what I want to point out to. It is called "blocked crawling of https"
Do this:
RewriteCond %{REQUEST_URI} main
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.domain.com/folder1/folder2/login$1 [R,L]

Why not send a 301 redirect when forcing HTTPS by mod_rewrite?

There are a lots of example in the net which suggest to force HTTPS. E.g:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
I have nowhere found any example which uses a 301 Moved Permanentlyredirect. Why not?
Wouldn't this avoid further requests to the HTTP site? And Google search results pointing to the HTTP site?
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Why is this used by nobody? Or did I just overlooked somebody who uses it?
The [R] flag will force an external redirect, the default status being 302 (temporarily relocated). AFAIK, you can set it to 301 by using [R=302,L]
I do not know why you wouldn't use 301 instead of 302 in this context.

speicif HTTP url to HTTPS url (only one url)

I was searching on web for like 4 hours and tryeda almoast everything, but nothing worked.
All i want to do is force redirecting for norma url to https url, using .htaccess, example:
I want that when person visit:
- http://www.mydomain.com/index.php?option=com_dms&task=checkout&Itemid=816
See:
- https://www.mydomain.com/index.php?option=com_dms&task=checkout&Itemid=816
that's pretty much all, I hope this is simple enough.
Thanks for answers in advance!
To do it only for your URL, this should work :
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^http://www\.mydomain\.com/index\.php?option=com_dms&task=checkout&Itemid=816$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Replace the URL by .* for all traffic.

Resources