diff --git a/src/system/modules/metamodels/MetaModelBackend.php b/src/system/modules/metamodels/MetaModelBackend.php
index <HASH>..<HASH> 100644
--- a/src/system/modules/metamodels/MetaModelBackend.php
+++ b/src/system/modules/metamodels/MetaModelBackend.php
@@ -85,6 +85,14 @@ class MetaModelBackend
 		$Env->base = $Env->url . $GLOBALS['TL_CONFIG']['websitePath'] . '/';
 		$Env->script = preg_replace('/^' . preg_quote($GLOBALS['TL_CONFIG']['websitePath'], '/') . '\/?/i', '', $Env->scriptName);
 
+		// Bugfix: If the user is not authenticated, contao will redirect to contao/index.php
+		// But in this moment the TL_PATH is not defined, so the $this->Environment->request
+		// generate a url without replacing the basepath(TL_PATH) with an empty string.
+		if(!defined(TL_PATH))
+		{
+			define('TL_PATH', $GLOBALS['TL_CONFIG']['websitePath']);
+		}
+		
 		// TODO: double, triple and quadro check that this is really safe context here.
 		$objUser->authenticate();
 		// restore initial settings.
Bugfix for login after the session died.