diff --git a/restws.module b/restws.module
index e078411..66eee17 100644
--- a/restws.module
+++ b/restws.module
@@ -190,6 +190,52 @@ class RestWSException extends Exception {
 }
 
 /**
+ * Implements hook_init().
+ *
+ * Sets the router item for the current path when it has a format.
+ */
+function restws_init() {
+  _restws_reroute_format_requests();
+}
+
+/**
+ * Reroute requests that come from *.{format} paths.
+ * For example /node/2.json will need a correct page callback to be treated as
+ * a restws request.
+ *
+ * Also, the restws_basic_auth module will need to use this function as well
+ * to perform this again after logging a user in.
+ */
+function _restws_reroute_format_requests() {
+  if (strpos(request_path(), '.') === FALSE) {
+    return;
+  }
+  $menu_paths = array();
+  foreach (restws_get_resource_info() as $resource => $info) {
+    $menu_paths[] = isset($info['menu_path']) ? $info['menu_path'] : $resource;
+  }
+  $formats = array_keys(restws_get_format_info());
+
+  $pattern = '#^((?:';
+  $pattern .= implode($menu_paths,'|');
+  $pattern .= ')\/[1-9][0-9]*)\.(?:';
+
+  $pattern .= implode($formats,'|');
+  $pattern .= ')$#i';
+
+  // Replace pattern precisely once.
+  $count = 0;
+  $path = preg_replace($pattern, '\1', request_path(), 1, $count);
+
+  // When the pattern matches and there is no menu router for the request
+  // path, substitute this module's page callback.
+  if ($count && !menu_get_item()) {
+    $router_item = menu_get_item($path);
+    menu_set_item(NULL, $router_item);
+  }
+}
+
+/**
  * Implements hook_menu_alter().
  */
 function restws_menu_alter(&$items) {
diff --git a/restws_basic_auth/restws_basic_auth.module b/restws_basic_auth/restws_basic_auth.module
index 69dc908..fc8de43 100644
--- a/restws_basic_auth/restws_basic_auth.module
+++ b/restws_basic_auth/restws_basic_auth.module
@@ -33,6 +33,10 @@ function restws_basic_auth_init() {
         // Always make sure to disable the page cache after we authenticated the
         // user so that a response never gets into the page cache.
         drupal_page_is_cacheable(FALSE);
+
+        // Because we need to redetermine the page callback for
+        // /node/{id}.{format} calls, we call this.
+        _restws_reroute_format_requests();
       }
       else {
         // Clear the login form error and remove the login failure message.
