Results 1 to 16 of 16
-
04-15-2011, 03:06 AM #1Junior Guru Wannabe
- Join Date
- May 2010
- Posts
- 40
WHMCS detect if https then convert all urls to https
Hi,
I am facing a big challenge with WHMCS. I installed SSL certficate and in firefox everything works fine but in IE I got annoying popup saying that this page has unsecure items.
I want to have function that detect that if I am on https then all links will change from http to https for e.g. http://www.domain.com/images/logo.php to https://www.domain.com/images/logo.php and so on.
This works fine when I hardcode everything but when I go out of secure path everything messed up because it calls my homepage i.e. https://www.domain.com instead http://www.domain.com
I found this piece of code and it doesn't work with whmcs.
if ($_SERVER['HTTPS']!="on") {
$url = "https://".$_SERVER["HTTP_HOST"]."/".$_SERVER["REQUEST_URI"];
header("Location: $url");
exit;
}
I am thinking a way around to create something like this:
<a href="page.php" {php if ($securepage == 'https://') { }else="http://"{php } }>
Thanks for your help.
-
04-15-2011, 04:20 AM #2Aspiring Evangelist
- Join Date
- Apr 2009
- Location
- Bangladesh
- Posts
- 406
do you have ssl installed on your whole website (all subdomains) ? If you don't then its not a good idea to use https for them. When the user will try to access with https on a non-https page, he/she will get an error.
If you do have https for all your pages, then why do you need to change the links to https only when user is on https ? You can edit the WHMCS templates and change the links to https permanently. You don't need to use php for that.
If you still want to do what you're trying to do, then ask again and I'll help.Sajid Iftekhar - Web Design Portfolio
-
04-15-2011, 04:50 AM #3Junior Guru Wannabe
- Join Date
- May 2010
- Posts
- 40
Hi Sajid213,
Thanks very much for the reply. I really want to do in my way. I think you will good picture of my situation after visitng my website:
http://www.mywebhosted.com/support/
So All header and footer links are http and they remain http even in https url i.e. order form
============
http urls
============
Home
Domain Registration
Domain Reseller
etc...
============
https form
============
https://www.mywebhosted.com/support/order/?pid=1&skip=1
If somehow I can manage to get header and footer links i.e. Home, Domain Registration, Domain Reseller in https when I am in secure url then it will be great and I will get rid of IE annoying message.
Another problem is after converting http link into https if customer clicks any of unsecure page and it is https then they will remain in secure url even page is static.
It will be great if somehow I can force everything to be https in secure location and http in unsecure location.
-
04-15-2011, 04:59 AM #4Aspiring Evangelist
- Join Date
- Apr 2009
- Location
- Bangladesh
- Posts
- 406
Ok I think i understand. This code is untested, so it might not work as expected:
HTML Code:<a href="{php}echo ($_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://');{/php}mydomain.com/page.php">
Sajid Iftekhar - Web Design Portfolio
-
04-15-2011, 05:31 AM #5Junior Guru Wannabe
- Join Date
- May 2010
- Posts
- 40
Thanks, I will try that and update you soon.
-
04-15-2011, 05:23 PM #6Junior Guru Wannabe
- Join Date
- May 2010
- Posts
- 40
Wow, works great. I have done some customization in my root .htaccess file to force all unsecure urls to http even if it https.
Code:RewriteCond %{HTTP_HOST} \. RewriteCond %{HTTP_HOST} !^www\.mywebhosted\.com [NC] RewriteRule (.*) http://www.mywebhosted.com/$1 [R=301,L] RewriteCond %{SERVER_PORT} !^80$ RewriteRule (.*) http://www.mywebhosted.com/$1 [R=301,L]
Code:<a href="{php}echo ($_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://');{/php}www.mywebhosted.com/domain-registration.php">
Code:<a href="{php}echo ($_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://');{/php}../domain-registration.php">
if ($_SERVER['HTTPS'] != "on") {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit;
}
Thanks
-
04-15-2011, 06:22 PM #7Newbie
- Join Date
- Jul 2008
- Posts
- 7
^thanks for posting that!
-
04-16-2011, 12:34 PM #8Aspiring Evangelist
- Join Date
- Apr 2009
- Location
- Bangladesh
- Posts
- 406
No, if you use the http/https protocols, your URLs must be absolute. If you want to make things easier, maybe you can try this code. Again, I'm not sure if it will work since its untested.
Go to your WHMCS template's header.tpl file and at the very top, put this:
PHP Code:{php}
$p = ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http');
$url = $p.'://www.mywebhosted.com/'; // This is the url of your main site
$whmcs = $p.'://www.mywebhosted.com/support/'; // This is the url of your whmcs folder
{/php}
HTML Code:<a href="{php}echo $url;{/php}page_of_main_site.php">
HTML Code:<a href="{php}echo $whmcs;{/php}clientarea.php">
Edit:
I found this code but dont know how to use it properly.
if ($_SERVER['HTTPS'] != "on") {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header("Location: $url");
exit;
}Sajid Iftekhar - Web Design Portfolio
-
04-20-2011, 07:16 PM #9Newbie
- Join Date
- Apr 2011
- Location
- Leicester, UK
- Posts
- 16
I have raised the very same issue with WHMCS but they didn't understand what I meant even though I have taken screenshots of the errors. I wouldn't of minded if I had integrated my template into WHMCS as it would of been my mistake, but I paid them to do it and get the IE error saying that the security of the web page is going to be compromised as some parts of the page are unsecure. I will try your code in the morning Sajid213 and let you know how I get on. Thanks for this.
-
04-21-2011, 11:42 AM #10Web Hosting Master
- Join Date
- Jun 2003
- Location
- Sheffield
- Posts
- 810
pwh-Kieran: Please advise the Ticket ID and I'll see what I can find.
-
04-21-2011, 11:48 AM #11Newbie
- Join Date
- Apr 2011
- Location
- Leicester, UK
- Posts
- 16
Hello Chickndip, Thank you for replying. I think I have resolved this issue myself now. But if you still wish to take a look at the Ticket then the ID is 927951.
-
04-21-2011, 01:13 PM #12Aspiring Evangelist
- Join Date
- Apr 2009
- Location
- Bangladesh
- Posts
- 406
Sajid Iftekhar - Web Design Portfolio
-
04-21-2011, 01:21 PM #13Newbie
- Join Date
- Apr 2011
- Location
- Leicester, UK
- Posts
- 16
I will do chickndip, thanks for your assistance. I presume your part of the WHMCS Support & Services team?
-
04-21-2011, 01:23 PM #14Web Hosting Master
- Join Date
- Jun 2003
- Location
- Sheffield
- Posts
- 810
OK I'm glad to hear you were able to get the issue sorted, there isn't much for me to look at in that case.
I'm not a member of the services team, but I do work for WHMCS.
-
04-21-2011, 01:45 PM #15Junior Guru Wannabe
- Join Date
- May 2010
- Posts
- 40
Sorry haven't got time. I will try your enhanced code and update the thread.
Last edited by khurramalvi; 04-21-2011 at 01:59 PM.
-
04-21-2011, 02:58 PM #16Junior Guru Wannabe
- Join Date
- May 2010
- Posts
- 40
Sajid213 you are star man. Just one thing I have to put {php} twice, h eader and footerotherwise it takes whmcs path.
http://www.mywebhosted.com/support
Any advice.
Similar Threads
-
https iframe in https page question
By diesel12 in forum Web Design and ContentReplies: 0Last Post: 11-04-2010, 03:21 PM -
Https or not?
By bambinou in forum Ecommerce Hosting & DiscussionReplies: 21Last Post: 09-11-2009, 06:17 PM -
Force HTTPS on WHMCS
By HostedPlanet in forum Hosting Software and Control PanelsReplies: 5Last Post: 09-09-2009, 04:08 PM -
SSL on https://domain.com vs https://www.domain.com
By sbogde in forum Hosting Security and TechnologyReplies: 3Last Post: 10-02-2007, 05:40 AM -
HTTPS URLs
By alex-info in forum Web HostingReplies: 14Last Post: 11-07-2003, 06:49 PM