diff --git a/core/templates/login.php b/core/templates/login.php
index bedff4453b0fb8282297d58ea13948cf42ee18fd..bb7a8337523aad6f3b0dc05fd0faf3fbee2b8ae6 100644
--- a/core/templates/login.php
+++ b/core/templates/login.php
@@ -1,5 +1,5 @@
 <!--[if IE 8]><style>input[type="checkbox"]{padding:0;}</style><![endif]-->
-<form action="index.php" method="post">
+<form method="post">
 	<fieldset>
 		<?php if(!empty($_['redirect'])) { echo '<input type="hidden" name="redirect_url" value="'.$_['redirect'].'" />'; } ?>
 		<?php if($_['display_lostpassword']): ?>
diff --git a/lib/base.php b/lib/base.php
index b89859ab2dd13387ed0b22393ead1fd5cd4677d8..41ff1870059a297f6fa74bb2460f40a48fc6a5c6 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -549,7 +549,8 @@ class OC{
 			else {
 				OC_User::unsetMagicInCookie();
 			}
-			OC_Util::redirectToDefaultPage();
+			header( 'Location: '.$_SERVER['REQUEST_URI'] );
+			exit();
 		}
 		return true;
 	}