diff --git a/phpBB/phpbb/controller/helper.php b/phpBB/phpbb/controller/helper.php
index dbf7a9307a..cc0dfdb607 100644
--- a/phpBB/phpbb/controller/helper.php
+++ b/phpBB/phpbb/controller/helper.php
@@ -71,7 +71,8 @@ class helper
 	* @param \phpbb\template\template $template Template object
 	* @param \phpbb\user $user User object
 	* @param \phpbb\config\config $config Config object
-	* @param \phpbb\controller\provider $provider Path provider
+	 *
+	 * @param \phpbb\controller\provider $provider Path provider
 	* @param \phpbb\extension\manager $manager Extension manager object
 	* @param \phpbb\symfony_request $symfony_request Symfony Request object
 	* @param \phpbb\request\request_interface $request phpBB request object
@@ -146,7 +147,7 @@ class helper
 		if ($this->config['force_server_vars'])
 		{
 			$context->setHost($this->config['server_name']);
-			$context->setScheme(substr($this->config['server_protocol'], -4));
+			$context->setScheme(substr($this->config['server_protocol'], 0, -3));
 			$context->setHttpPort($this->config['server_port']);
 			$context->setHttpsPort($this->config['server_port']);
 			$context->setBaseUrl($this->config['script_path']);
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index b3ec8b256a..ea77a289c9 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -435,14 +435,14 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
 	public function helper_url_data_force_server_vars()
 	{
 		return array(
-			array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'),
-			array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/foo'),
-			array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'),
-			array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/foo'),
-			array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'),
-			array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'),
-			array(false, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'),
-			array(true, true, 'my_server', 443, '/my/board', 'http', UrlGeneratorInterface::RELATIVE_PATH, 'foo'),
+			array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'),
+			array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::ABSOLUTE_URL, 'https://my_server:444/my/board/foo'),
+			array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:443/my/board/app.php/foo'),
+			array(true, true, 'my_server', 444, '/my/board', 'https://', UrlGeneratorInterface::NETWORK_PATH, '//my_server:444/my/board/foo'),
+			array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/app.php/foo'),
+			array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_PATH, '/my/board/foo'),
+			array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'app.php/foo'),
+			array(true, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::RELATIVE_PATH, 'foo'),
 		);
 	}