SSL Certificates

Soldato
Joined
30 Apr 2007
Posts
3,095
Location
Kent
I've recently had an SSL Certificate installed a site (with TSO Host), which is based on OpenCart. To make sure everything is secured, I've added a ModRewrite rule within .htaccess as follows:

Code:
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mysite.co.uk/$1 [R,L]

Is it OK to do it that way? Or should I be using another solution.

Many thanks.
 
This is mine with opencart and tsohosts ssl

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blahh.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.blahh.co.uk$
RewriteRule ^/?$ http://www.blahh.co.uk/shop/ [R=301,L]

Dunno if it helps im new to all this myself.
 
I've recently had an SSL Certificate installed a site (with TSO Host), which is based on OpenCart. To make sure everything is secured, I've added a ModRewrite rule within .htaccess as follows:

Code:
RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.mysite.co.uk/$1 [R,L]

Is it OK to do it that way? Or should I be using another solution.

Many thanks.
Nothing wrong with that. If you want to force it for a different folder on your webhost just add a second condition:

Code:
RewriteCond %{request_uri} [I]folder name[/I]

just for "good practice" though, ie if you were using a webhost you weren't sure about you could use

Code:
<IfModule mod_rewrite.c>
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteCond %{SERVER_PORT}!^443$
RewriteCond %{request_uri} [I]folder name[/I]
RewriteRule ^(.*)$ https://www.site.co.uk/$1 [R,L]
</IfModule>

or you could be more sophisticated, and just force ssl on certain pages as its an unnecessary overhead otherwise:

Code:
RewriteCond %{SERVER_PORT} !^443$ 
RewriteRule ^(login|account|order|signup|payscreen|shoppingcart(?![-s])).*$ https://%{SERVER_NAME}/$0 [L] 
RewriteCond %{SERVER_PORT} ^443$ 
RewriteRule ^index.php/(?!login|account|order|signup|payscreen|shoppingcart)(.*)$ http://%{SERVER_NAME}/$1$2 [L] 
RewriteCond %{SERVER_PORT} ^443$ 
RewriteRule ^$ http://%{SERVER_NAME} [L]
 
Last edited:
Back
Top Bottom