When I enter the url it will redirect to http://www.xyz.in, but if I edit it to https://www.xyz.in, the SSL certificate starts working.
The problem is how to redirect to https://www.xyz.in when the user enters xyz.in
Config file:
$root = (isset($_SERVER['HTTPS']) ? "https://" : "http://") . $_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$config['base_url'] = $root;
.htaccess file:
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} (www.)?xyx.in
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
I have tried changing RewriteCond %{HTTPS} off
to on
, but it always redirects to http://xyz.in.
2
Answers
I think changing
(.*)
to^
should work out. Let me know if it doesn’t. Also, make sure mod_rewrite is enabled. Clear your browser’s cache and try this.Try this out. It should work.