helpfulguy
helpfulguy

Reputation: 1

Force redirect HTTP to HTTPS (Opencart v1.5.6.4)

So, am helping a guy to redirect all HTTP requests to HTTPS but keep on getting loop error when adding any of these in .htaccess.

ReWriteCond %{SERVER_PORT} 80   
Or
RewriteCond %{HTTP:X-Forwarded-Proto} !https
Or 
RewriteCond %{HTTPS} off
Or
RewriteCond %{HTTPS} !on
Or
RewriteCond %{HTTP:X-Forwarded-SSL} =off

This is a shared hosting (if that even matters). This is the phpinfo file and am not too sure how I can use this via .htaccess like what this guy suggested

_SERVER["https_proxy"]  

http://www.supawhip.com.au/phpinfo.php

Upvotes: 0

Views: 678

Answers (1)

kanenas
kanenas

Reputation: 879

In .htaccess try this:

<IfModule mod_rewrite.c>
RewriteEngine On
# This will enable the Rewrite capabilities

RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
# This rule will redirect users from their original location, to the same location but using HTTPS.
# i.e.  http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in httpd.conf
# or .htaccess context
</IfModule>

also in /config.php

// HTTP
define('HTTP_SERVER', 'https://www.supawhip.com.au/');
// HTTPS
define('HTTPS_SERVER', 'https://www.supawhip.com.au/');

and in /admin/config.php

// HTTP
define('HTTP_SERVER', 'https://www.supawhip.com.au/admin/');
define('HTTP_CATALOG', 'https://www.supawhip.com.au/');

// HTTPS
define('HTTPS_SERVER', 'https://www.supawhip.com.au/admin/');
define('HTTPS_CATALOG', 'https://www.supawhip.com.au/');

Upvotes: 1

Related Questions