PDA

View Full Version : Force SSL/HTTPS



tj
09-06-06, 09:09 PM
I get first post in this forum! :P

Ok well I hope some of you will find this useful!

Its a line of php that will redirect the users browser to the SSL'd version of your WHM system.

If a user types the url of your system directly as:
http://billing.webhost.com, nothing exchanged between the system and the user is encrypted leaving the information exposed.

With the code below



{php}
/* redirect to secure site ALWAYS?? */
if ($_SERVER["SERVER_PORT"] != 443)
{
header('Location: https://billing.webhost.com/index.php');
}
{/php}


If a user where to type http://billing.webhost.com he/she will be redirected to https://billing.webhost.com.

Just paste that in at the top of your header.tpl file.
And dont forget to change the https://billing.webhost.com/index.php to your url!

Just my two cents :)

xxkylexx
09-07-06, 12:42 AM
The following method might work a bit better, since it will force https:// for any URL that is entered in http:// form, not just redirect to the index page. This will only work if the billing software is on it's own domain or subdomain, however.

Put the following in .htaccess or in your httpd.conf:



RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


You can see this working with some of the following links on my site, which are in http:// form below:
http://members.websolvents.com/
http://members.websolvents.com/knowledgebase.php?action=displayarticle&catid=3&id=14
http://members.websolvents.com/domainchecker.php


Enjoy!

Kyle

MACscr
09-07-06, 03:46 AM
Or you can try this, which gives you the benefits of both worlds.

http://www.whmcs.com/forums/viewtopic.php?t=1067&highlight=

Adam
09-22-06, 04:38 AM
Hey,

I like Kyle's method better as this would be for the whole folder, sub-domain or domain - where ever the .htaccess file is located...

From,
Adam

MACscr
09-22-06, 04:52 AM
true, it would work that way, but using it for the knowledgebase, tutorials, homepage, etc, is just a waste of resources IMHO. https uses more resources and of course then,is slower. But hey, to each his own.

imaginit
12-19-06, 08:34 PM
Works like a charm MACscr! Thanks for sharing! You also just opened my complex eyes to how simple it really is to add to this system! Thanks for that as well!