not redirecting to HTTPS from HTTP

Multi tool use
Multi tool use


not redirecting to HTTPS from HTTP



I had tried every method of redirection i.e .htaccess but none of the things work for me. as right now the .htaccess file contains


.htaccess


.htaccess


RewriteCond %{REQUEST_URI} !^/[0-9]+..+.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9]{32}.txt(?: Comodo DCV)?$
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.booksoncall.in/$1 [R=301,L]



it work fine on my computer and the http is redirecting successfully to https version, but http version is still accessable on other pc and is not redirecting to https same is happening on mobile devices.
website --- booksoncall.in





Where exactly did you place this .htaccess file, is it in the web root of the domain? Why are you checking for port 80, there are other more common ways to check if the request was made via HTTPS or not.
– CBroe
Jul 3 at 8:00





are htaccess files authorized by your apache config ?
– ᴄʀᴏᴢᴇᴛ
Jul 3 at 8:02





Did you look at your logfiles?
– Patrick Mevzek
Jul 3 at 16:35




3 Answers
3



Give this a try if you want all requests to be redirected to https


RewriteEngine on
RewriteCond %{SERVER_NAME} = example.com [OR]
RewriteCond %{SERVER_NAME} = www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]



This should be done in the Vhost file for port 80





Your RewriteCond syntax is wrong (you do not use =). and also your setup will never work as multiple RewriteCond are parsed as AND together so the server name can not be both strings at the same time. See httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewritecond
– Patrick Mevzek
Jul 3 at 14:26



RewriteCond


=


RewriteCond





Thanks for your input @PatrickMevzek - I forgot the [OR] statement in my example. Edited my answer.
– Sourcey86
Jul 4 at 7:03



for short version.
you dont need the server name.


RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]



If you want to redirect all http request to https why not use


<VirtualHost 0.0.0.0:80>

ServerName www.example.com:80

Redirect permanent / https://www.example.com/

</VirtualHost>






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

t6xafIfEX,rH5vaBkcGhM,ZC5T65O,6wsihiCi G4,MgPJuT
fg5 QDs,Ohd63lzj,O,hxm 2LulXBb1tm5NO,RfXW,LZtDdFhD0 8,NY1 Y Olu8y06Lymg9toAz t2sLOuuZ,BvL7NoyhdI8a07

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications