diff --git a/core/js/js.js b/core/js/js.js
index 39a58a245993ffcdf794d3cef4fa4efe22e9751d..ffe3507a4ebe777af2bfe8b8670eb6e19dba369d 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -88,7 +88,12 @@ var OC={
 			}
 			link+=file;
 		}else{
-			link+='/';
+			if (app == 'settings' && type == 'ajax') {
+				link+='/index.php/';
+			}
+			else {
+				link+='/';
+			}
 			if(!isCore){
 				link+='apps/';
 			}
diff --git a/core/routes.php b/core/routes.php
index 9a84eb64a3b368d4bb520145cbda8b61c7e1ddba..b0f41dd286111e25bb2a1676b965232853bf3c8c 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -6,19 +6,7 @@
  * See the COPYING-README file.
  */
 
-// Core settings pages
-$this->create('settings_help', '/settings/help')
-	->actionInclude('settings/help.php');
-$this->create('settings_personal', '/settings/personal')
-	->actionInclude('settings/personal.php');
-$this->create('settings_settings', '/settings')
-	->actionInclude('settings/settings.php');
-$this->create('settings_users', '/settings/users')
-	->actionInclude('settings/users.php');
-$this->create('settings_apps', '/settings/apps')
-	->actionInclude('settings/apps.php');
-$this->create('settings_admin', '/settings/admin')
-	->actionInclude('settings/admin.php');
+require_once('settings/routes.php');
 
 // Not specifically routed
 $this->create('app_css', '/apps/{app}/{file}')
diff --git a/settings/ajax/apps/ocs.php b/settings/ajax/apps/ocs.php
index fb78cc89248471008532c2be7fcc7a8aca3a65d8..4d6f1116e7d69b81f863d4236dcd50bf81629641 100644
--- a/settings/ajax/apps/ocs.php
+++ b/settings/ajax/apps/ocs.php
@@ -6,9 +6,6 @@
  * See the COPYING-README file.
  */
 
-// Init owncloud
-require_once '../../../lib/base.php';
-
 OC_JSON::checkAdminUser();
 
 $l = OC_L10N::get('settings');
diff --git a/settings/ajax/changepassword.php b/settings/ajax/changepassword.php
index b251fea504b9e89df86543affc05effa70818802..200fdec26dea6837facd37a9f77a747b3a59b0fa 100644
--- a/settings/ajax/changepassword.php
+++ b/settings/ajax/changepassword.php
@@ -1,7 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
 OCP\JSON::callCheck();
 
 $username = isset($_POST["username"]) ? $_POST["username"] : OC_User::getUser();
diff --git a/settings/ajax/creategroup.php b/settings/ajax/creategroup.php
index 83733ac4d2d58c130f447504b07bf5c02c6cb85d..bb3b0620e8a2b8bd96c0cbd13ec17eced184efec 100644
--- a/settings/ajax/creategroup.php
+++ b/settings/ajax/creategroup.php
@@ -1,7 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
 OCP\JSON::callCheck();
 
 // Check if we are a user
diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php
index bdf7e4983ac5fd5f12674bb0db9a721de01442f3..49fc0e0f53b6bafb653513fb84c97e6e73fe9efe 100644
--- a/settings/ajax/createuser.php
+++ b/settings/ajax/createuser.php
@@ -1,7 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
 OCP\JSON::callCheck();
 
 // Check if we are a user
diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php
index 977a536af215d084e39584a50dd3d8c89f4ceea1..a39b06b9c7d6ffa27287cf6c005cf7f57e9c7b44 100644
--- a/settings/ajax/disableapp.php
+++ b/settings/ajax/disableapp.php
@@ -1,6 +1,4 @@
 <?php
-// Init owncloud
-require_once '../../lib/base.php';
 OC_JSON::checkAdminUser();
 OCP\JSON::callCheck();
 OC_JSON::setContentTypeHeader();
diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php
index c3b3491db931f9d706a3f89eacac03b8a2f23200..f4d5c53adeff3af09cb623e2cb08be6e9ba3a6d3 100644
--- a/settings/ajax/enableapp.php
+++ b/settings/ajax/enableapp.php
@@ -1,7 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
 OC_JSON::checkAdminUser();
 OCP\JSON::callCheck();
 OC_JSON::setContentTypeHeader();
diff --git a/settings/ajax/getlog.php b/settings/ajax/getlog.php
index 9b9240f82539224083233bcb886d4dad56abf2b2..22128ef57b53278ae3fa1f0e9ab76badb74d10dd 100644
--- a/settings/ajax/getlog.php
+++ b/settings/ajax/getlog.php
@@ -5,9 +5,6 @@
  * See the COPYING-README file.
  */
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 OC_JSON::checkAdminUser();
 
 $count=(isset($_GET['count']))?$_GET['count']:50;
diff --git a/settings/ajax/lostpassword.php b/settings/ajax/lostpassword.php
index 2a40ba09a8ac3506af2050b0b5e191897b2db28b..b5f47bbceabe88a41464da3ed6283b14f3b85744 100644
--- a/settings/ajax/lostpassword.php
+++ b/settings/ajax/lostpassword.php
@@ -1,7 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
 OC_JSON::checkLoggedIn();
 OCP\JSON::callCheck();
 
diff --git a/settings/ajax/openid.php b/settings/ajax/openid.php
index ecec085383c1124c599c3c7f6f1cb205ccdcfcd0..23c43c3c48eb209db10b5dfce13c86a0156776d4 100644
--- a/settings/ajax/openid.php
+++ b/settings/ajax/openid.php
@@ -1,8 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 $l=OC_L10N::get('settings');
 
 OC_JSON::checkLoggedIn();
diff --git a/settings/ajax/removegroup.php b/settings/ajax/removegroup.php
index 33e1a514c88e8b55964a0a530a095cff2f4cbb5a..798d7916e61f2de452e0abf90ebcd6354df28a9f 100644
--- a/settings/ajax/removegroup.php
+++ b/settings/ajax/removegroup.php
@@ -1,8 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 OC_JSON::checkAdminUser();
 OCP\JSON::callCheck();
 
diff --git a/settings/ajax/removeuser.php b/settings/ajax/removeuser.php
index 6b11fa5c4fb548e707f9e8ad3657dca699899f8e..a10dc29321d8abc02ba8888b753ddb5446e9ff64 100644
--- a/settings/ajax/removeuser.php
+++ b/settings/ajax/removeuser.php
@@ -1,8 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 OC_JSON::checkSubAdminUser();
 OCP\JSON::callCheck();
 
diff --git a/settings/ajax/setlanguage.php b/settings/ajax/setlanguage.php
index 42eea7a96fdc03bb793fbd2e7bc17694d2832da0..aebb1b31b6f9f0bfad0cd77f169119a1f057ba99 100644
--- a/settings/ajax/setlanguage.php
+++ b/settings/ajax/setlanguage.php
@@ -1,8 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 $l=OC_L10N::get('settings');
 
 OC_JSON::checkLoggedIn();
diff --git a/settings/ajax/setloglevel.php b/settings/ajax/setloglevel.php
index 982899e106adbb09355a103863cae73a8e95f491..542219f86c63cf3b9fb35522f65c2892695d3d17 100644
--- a/settings/ajax/setloglevel.php
+++ b/settings/ajax/setloglevel.php
@@ -5,7 +5,6 @@
  * See the COPYING-README file.
  */
 
-require_once '../../lib/base.php';
 OC_Util::checkAdminUser();
 OCP\JSON::callCheck();
 
diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php
index 2352ae9e4276cac802fbdbdf38e0c39b1aabc6b8..4b32585b3066cff0f955f33e4b88ce582bd7f94e 100644
--- a/settings/ajax/setquota.php
+++ b/settings/ajax/setquota.php
@@ -5,9 +5,6 @@
  * See the COPYING-README file.
  */
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 OC_JSON::checkSubAdminUser();
 OCP\JSON::callCheck();
 
diff --git a/settings/ajax/togglegroups.php b/settings/ajax/togglegroups.php
index 65747968c172bf62abf8665750757260e7af511c..de941f991320f7fffb5b101ab910f339e2fbe996 100644
--- a/settings/ajax/togglegroups.php
+++ b/settings/ajax/togglegroups.php
@@ -1,8 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 OC_JSON::checkSubAdminUser();
 OCP\JSON::callCheck();
 
diff --git a/settings/ajax/togglesubadmins.php b/settings/ajax/togglesubadmins.php
index 5f7126dca347dd94ce0c8dd853737a09afb35b8e..7aaa90aad5fbd1ae159d6062c85e6266bdb2f570 100644
--- a/settings/ajax/togglesubadmins.php
+++ b/settings/ajax/togglesubadmins.php
@@ -1,8 +1,5 @@
 <?php
 
-// Init owncloud
-require_once '../../lib/base.php';
-
 OC_JSON::checkAdminUser();
 OCP\JSON::callCheck();
 
@@ -16,4 +13,4 @@ if(OC_SubAdmin::isSubAdminofGroup($username, $group)) {
 	OC_SubAdmin::createSubAdmin($username, $group);
 }
 
-OC_JSON::success();
\ No newline at end of file
+OC_JSON::success();
diff --git a/settings/ajax/userlist.php b/settings/ajax/userlist.php
index 840b6d72dc7bfd861616025ad976c2fdf48fd0f5..61b1a388fc33154d57fabff468ecb7f18a9e54d2 100644
--- a/settings/ajax/userlist.php
+++ b/settings/ajax/userlist.php
@@ -20,8 +20,6 @@
  *
  */
 
-require_once '../../lib/base.php';
-
 OC_JSON::callCheck();
 OC_JSON::checkSubAdminUser();
 if (isset($_GET['offset'])) {
@@ -49,4 +47,4 @@ if (OC_Group::inGroup(OC_User::getUser(), 'admin')) {
 			'quota' => OC_Preferences::getValue($user, 'files', 'quota', 'default'));
 	}
 }
-OC_JSON::success(array('data' => $users));
\ No newline at end of file
+OC_JSON::success(array('data' => $users));
diff --git a/settings/js/users.js b/settings/js/users.js
index 20bd94993bce5f309d1df454588dd22a2912efc4..81a3181ba59562dc7fcfcdc03b0c9792eb0efd5d 100644
--- a/settings/js/users.js
+++ b/settings/js/users.js
@@ -130,7 +130,7 @@ var UserList={
 		if (typeof UserList.offset === 'undefined') {
 			UserList.offset = $('tbody tr').length;
 		}
-		$.get(OC.filePath('settings', 'ajax', 'userlist.php'), { offset: UserList.offset }, function(result) {
+		$.get(OC.filePath('settings', 'ajax', 'userlist'), { offset: UserList.offset }, function(result) {
 			if (result.status === 'success') {
 				$.each(result.data, function(index, user) {
 					var tr = UserList.add(user.name, user.groups, user.subadmin, user.quota, false);
diff --git a/settings/routes.php b/settings/routes.php
new file mode 100644
index 0000000000000000000000000000000000000000..b64a357be0ec4ccbc8b521c54e2c29be48493fbc
--- /dev/null
+++ b/settings/routes.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+// Settings pages
+$this->create('settings_help', '/settings/help')
+	->actionInclude('settings/help.php');
+$this->create('settings_personal', '/settings/personal')
+	->actionInclude('settings/personal.php');
+$this->create('settings_settings', '/settings')
+	->actionInclude('settings/settings.php');
+$this->create('settings_users', '/settings/users')
+	->actionInclude('settings/users.php');
+$this->create('settings_apps', '/settings/apps')
+	->actionInclude('settings/apps.php');
+$this->create('settings_admin', '/settings/admin')
+	->actionInclude('settings/admin.php');
+// Settings ajax actions
+// users
+$this->create('settings_admin', '/settings/ajax/userlist')
+	->actionInclude('settings/ajax/userlist.php');
+$this->create('settings_ajax_createuser', '/settings/ajax/createuser.php')
+	->actionInclude('settings_ajax_createuser');
+$this->create('settings_ajax_removeuser', '/settings/ajax/removeuser.php')
+	->actionInclude('settings/ajax/removeuser.php');
+$this->create('settings_ajax_setquota', '/settings/ajax/setquota.php')
+	->actionInclude('settings/ajax/setquota.php');
+$this->create('settings_ajax_creategroup', '/settings/ajax/creategroup.php')
+	->actionInclude('settings_ajax_creategroup');
+$this->create('settings_ajax_togglegroups', '/settings/ajax/togglegroups.php')
+	->actionInclude('settings/ajax/togglegroups.php');
+$this->create('settings_ajax_togglesubadmins', '/settings/ajax/togglesubadmins.php')
+	->actionInclude('settings/ajax/togglesubadmins.php');
+$this->create('settings_ajax_removegroup', '/settings/ajax/removegroup.php')
+	->actionInclude('settings/ajax/removegroup.php');
+$this->create('settings_ajax_changepassword', '/settings/ajax/changepassword.php')
+	->actionInclude('settings/ajax/changepassword.php');
+// personel
+$this->create('settings_ajax_lostpassword', '/settings/ajax/lostpassword.php')
+	->actionInclude('settings/ajax/lostpassword.php');
+$this->create('settings_ajax_setlanguage', '/settings/ajax/setlanguage.php')
+	->actionInclude('settings/ajax/setlanguage.php');
+// apps
+$this->create('settings_ajax_apps_ocs', '/settings/ajax/apps/ocs.php')
+	->actionInclude('settings/ajax/apps/ocs.php');
+$this->create('settings_ajax_enableapp', '/settings/ajax/enableapp.php')
+	->actionInclude('settings/ajax/enableapp.php');
+$this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php')
+	->actionInclude('settings/ajax/disableapp.php');
+// admin
+$this->create('settings_ajax_getlog', '/settings/ajax/getlog.php')
+	->actionInclude('settings/ajax/getlog.php');
+$this->create('settings_ajax_setloglevel', '/settings/ajax/setloglevel.php')
+	->actionInclude('settings/ajax/setloglevel.php');
+
+// apps/user_openid
+$this->create('settings_ajax_openid', '/settings/ajax/openid.php')
+	->actionInclude('settings/ajax/openid.php');