MyBB Community Forums

Full Version: redirection to bad url: a bug ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,
I noticed a wrong behavior after upgrading my board from 1.2.14 to 1.6.1:
after logging in the redirection page points to a wrong url, http://my.web.site
instead of https://my.web.site, as it has always been.
(the Board URL value is correctly configured)

I looked in the redirect template, but I found only the placeholder href="{$url}

What can I do to fix this ? As my board only works with https.
Thanks,
Diab
In the adminCP underconfiguration you have to switch MyBB to use HTTPS in the URL area. If you need help i'll be able to after school.
Hi Aristotle, I looked through all Configuration/settings, but I didn't find it. Am I becoming stupid or it is very well hidden ? Smile

Bye,
Diab
Hi guys,
does anybody know hot to switch on HTTPS use on mybb 1.6.1 ?

Thx
I am not really familiar with 1.6.1 yet, but on 1.4 you had to make a few core file edits to get https to work.

In global.php below the require init.php :
if($_SERVER['HTTPS'] == on){
$settings['bburl'] = "https://domain.com";
}
else 
{
$settings['bburl'] = "http://domain.com";
}

There were a few more, but i forgot where lol. you get the drift though..
You'll probably have to edit some files. For example inc/functions.php

        $url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

change to https://

Another alternative would be redirecting from http:// to https://
(2011-01-28, 10:00 AM)Disturbed Wrote: [ -> ]In global.php below the require init.php :
if($_SERVER['HTTPS'] == on){
$settings['bburl'] = "https://domain.com";
}
else 
{
$settings['bburl'] = "http://domain.com";
}

Ummhhh... I'm not convinced about it, because in inc/settings.php, the parameter $settings['bburl'] is correctly configured to "https://my.web.site" via AdminCP/Configuration/General settings.

(2011-01-28, 11:22 AM)frostschutz Wrote: [ -> ]
        $url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

Hi frostschutz,
this resolved the issue, thanks !

I think this is a sort of "conceptual" bug, because cabling the protocol http:// in the php code cancels the flexibility given by using the setting $settings['bburl'], configurable via AdminCP.

Bye,
Diabolik
(2011-01-28, 03:23 PM)Diabolik Wrote: [ -> ]Ummhhh... I'm not convinced about it, because in inc/settings.php, the parameter $settings['bburl'] is correctly configured to "https://my.web.site" via AdminCP/Configuration/General settings.

Sorry i didn't notice your forum had to be accessible only through https and i don't use the annoying redirects..

Should have read better...




(2011-01-28, 03:23 PM)Diabolik Wrote: [ -> ]
(2011-01-28, 10:00 AM)Disturbed Wrote: [ -> ]In global.php below the require init.php :
if($_SERVER['HTTPS'] == on){
$settings['bburl'] = "https://domain.com";
}
else 
{
$settings['bburl'] = "http://domain.com";
}

Ummhhh... I'm not convinced about it, because in inc/settings.php, the parameter $settings['bburl'] is correctly configured to "https://my.web.site" via AdminCP/Configuration/General settings.

(2011-01-28, 11:22 AM)frostschutz Wrote: [ -> ]
        $url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

Hi frostschutz,
this resolved the issue, thanks !

I think this is a sort of "conceptual" bug, because cabling the protocol http:// in the php code cancels the flexibility given by using the setting $settings['bburl'], configurable via AdminCP.

Bye,
Diabolik

This is a bug actually. The code should be detecting which protocol to use, and using it dynamically.
All instances of hardcoded http:// protocol should be replaced by HTTP_PROTO (which we would need to set in init.php), so using the above example:
$url = htmlspecialchars_uni("http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
Would become:
$url = htmlspecialchars_uni(HTTP_PROTO.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);

And in init.php we have:
// Fix for people who for some specify a trailing slash on the board URL
if(substr($settings['bburl'], -1) == "/")
{
	$settings['bburl'] = my_substr($settings['bburl'], 0, -1);
}
And we would change that to:
// Fix for people who for some specify a trailing slash on the board URL
if(substr($settings['bburl'], -1) == "/")
{
	$settings['bburl'] = my_substr($settings['bburl'], 0, -1);
}

if(substr($settings['bburl'], 0, 5) == "https")
{
	define("HTTP_PROTO", "https");
}
else
{
	define("HTTP_PROTO", "http");
}
I've reported this on the dev site bug tracker for you.
Pages: 1 2