1

I need to redirect single html page to https. For this I've tried https://stackoverflow.com/questions/16152914/redirect-single-page-http-to-https this also. but it's not working.

my web url format is http://www.example.com/api/test.html , I need to convert this test.html page to https://www.example.com/api/test.html

any help please.

Community
  • 1
  • 1
Ripa Saha
  • 2,532
  • 6
  • 27
  • 51
  • @Rikesh I just checked it. and yes , it's off. so informing server administratot to open this. Thanks for Your suggestion. – Ripa Saha Nov 17 '14 at 13:04

3 Answers3

1

With PHP

if (!preg_match("/https/i", $_SERVER['SERVER_PROTOCOL'])) {
    header("Location: https://" .$_SERVER["SERVER_NAME"] ."/" . $_SERVER["REQUEST_URI"]);
    die();
}
vaso123
  • 12,347
  • 4
  • 34
  • 64
0

It should work,

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Dimag Kharab
  • 4,439
  • 1
  • 24
  • 45
0

You can use:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} \s/+api/test\.html[\s?] [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,NE,R=301]
anubhava
  • 761,203
  • 64
  • 569
  • 643