diff --git a/htdocs/lib/security.lib.php b/htdocs/lib/security.lib.php
index b49e598c3fdb819fa3961d6a81213d81c903833e..671572768f18a440b4e14c9ce1417d2b4715abd6 100644
--- a/htdocs/lib/security.lib.php
+++ b/htdocs/lib/security.lib.php
@@ -365,7 +365,8 @@ function dol_loginfunction($langs,$conf,$mysoc)
 	}
 	else
 	{
-		if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/login.tpl"))
+		if (file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/login.tpl")
+			|| file_exists(DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/login.tpl.php"))
 		{
 			$template_dir=DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/templates/";
 		}