Sahil Arora
Sahil Arora

Reputation: 1

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

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

Upvotes: 0

Views: 97

Answers (3)

Andre Gelinas
Andre Gelinas

Reputation: 912

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>

Upvotes: 0

MHopstad
MHopstad

Reputation: 333

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

Upvotes: 1

JayDee
JayDee

Reputation: 61

for short version. you dont need the server name.

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

Upvotes: 0

Related Questions