diff --git a/cas_server.module b/cas_server.module
index d86af23..3aaeabe 100644
--- a/cas_server.module
+++ b/cas_server.module
@@ -184,7 +184,12 @@ function cas_server_logout() {
   module_invoke_all('user', 'logout', NULL, $user);
   $output = '<p>You have been logged out successfully</p>'; 
   if ($_GET['url'])  {
-    $output .= '<p>'. l('Continue', $_GET['url']) .'</p>'; 
+    if ($_GET['gateway']) {
+      drupal_goto($_GET['url']);
+    }
+    else {
+      $output .= '<p>'. l('Continue', $_GET['url']) .'</p>';
+    }
   }
   return $output; 
 }
\ No newline at end of file
