0

I am using following code in .htaccess file. It's working fine only in chrome browser. I want to redirect from non www http or www http to https:// www

RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(/(.*))?$ https://%{www.happyvivah.in}/$1 [R=301,L]
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Sarita Sharma
  • 253
  • 2
  • 8
  • 19
  • 3
    Possible duplicate of [htaccess redirect to https://www](https://stackoverflow.com/questions/13977851/htaccess-redirect-to-https-www) –  Jul 23 '17 at 03:28

1 Answers1

0

you can do it on a php file on your php easily.

if (!(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || 
$_SERVER['HTTPS'] == 1) ||  
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&   
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
{
$redirect = 'https://' . $_SERVER['HTTP_HOST'] .   $_SERVER['REQUEST_URI'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $redirect);
exit();
}
Isidoro Barrera
  • 95
  • 1
  • 11