HTTPS problem, and fix.

Please report bugs here!

Moderator: Thorsten

Post Reply
ChrisA
Posts: 12
Joined: Wed Jan 01, 2014 1:59 pm

HTTPS problem, and fix.

Post by ChrisA »

Hi, I've installed my FAQ under the http://web.com/FAQ style path. My hosting comes with SSL, but I did not want to force it.

This caused a problem. The template param baseHref is set from the database which is in my case http://xxx. This is placed into the <base> tag and forces all links to use the db version of the address. On all my browsers, they will not receive files from http, while the page is using https which leaves the FAQ without css styling and javascript.

To fix this I added the following code into index.php above the array $tplMainPage

Code: Select all

if( $_ENV[ 'REQUEST_SCHEME' ] == 'https' ){

	if( strpos( $systemUri, 'https' ) === FALSE )
		$systemUri = str_replace( 'http://', 'https://', $systemUri );
}
Now all my FAQ's work on the client side. The same may have to be done to the admin pages. I haven't looked at that yet, I'm still setting my site up on a new server, which the FAQ wasn't too keen on either.
ChrisA
Posts: 12
Joined: Wed Jan 01, 2014 1:59 pm

Re: HTTPS problem, and fix.

Post by ChrisA »

Just had a look at the admin pages, they have the same problem.

In admin/header.php I changed:

Code: Select all

<base href="<?php print $faqConfig->get('main.referenceURL'); ?>/admin/" />
Into:

Code: Select all

    <base href="<?php 
	
		$__url = $faqConfig->get('main.referenceURL');
		if( $_ENV[ 'REQUEST_SCHEME' ] == 'https' ){

			if( strpos( $__url, 'https' ) === FALSE )
				$__url = str_replace( 'http://', 'https://', $__url );
		}		
		print $__url; 
	?>/admin/" />
Post Reply