diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
index d136f04f3eb5e7f90ea5bd7c2ffbbc761b0ee256..94d9abb6a253e2d76108ce025cf911fd6e9c8d9a 100644
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -20,10 +20,14 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
 	private static $tempFiles=array();
 	
 	public function __construct($params){
-		$this->host=$params['host'];
+		$host = $params['host'];
+		//remove leading http[s], will be generated in createBaseUri()
+		if (substr($host,0,8) == "https://") $host = substr($host, 8);
+		else if (substr($host,0,7) == "http://") $host = substr($host, 7);
+		$this->host=$host;
 		$this->user=$params['user'];
 		$this->password=$params['password'];
-		$this->secure=isset($params['secure'])?(bool)$params['secure']:false;
+		$this->secure=(isset($params['secure']) && $params['secure'] == 'true')?true:false;
 		$this->root=isset($params['root'])?$params['root']:'/';
 		if(!$this->root || $this->root[0]!='/'){
 			$this->root='/'.$this->root;
@@ -46,7 +50,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
 	private function createBaseUri(){
 		$baseUri='http';
 		if($this->secure){
-			$baseUri.'s';
+			$baseUri.='s';
 		}
 		$baseUri.='://'.$this->host.$this->root;
 		return $baseUri;