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 .
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
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.
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?xyz\.in
RewriteRule ^(.*)$ https://www.xyz.in/$1 [R=301,L]
Try this out. It should work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.