Reputation: 580
I have a problem, my project is running on nginx, so I cant do redirects via htaccess. Solution is that I need to use index.php using php to redirect http to https.
Example
http://example.com/shoes to https://example.com/shoes
Also, most of the examples on google suggest using htaccess, thats why I'm here.
Upvotes: 1
Views: 345
Reputation: 580
if(!$_SERVER['HTTPS'] || strtolower($_SERVER['HTTPS']) != 'on' ){
header("HTTP/1.1 301 Moved Permanently");
header('Location: https://' . str_replace('www.','',$_SERVER['HTTP_HOST']) . $_SERVER['REQUEST_URI']);
exit();
}
Found a solution that worked for me.
p.s. WWW str replace was additional functionality that isn't needed here
Upvotes: 2