diff --git a/include/obmc_console.hpp b/include/obmc_console.hpp
index 7eaa153..f9b978d 100644
--- a/include/obmc_console.hpp
+++ b/include/obmc_console.hpp
@@ -185,8 +185,7 @@
     auto iter = getConsoleHandlerMap().find(&conn);
     if (iter == getConsoleHandlerMap().end())
     {
-        BMCWEB_LOG_ERROR << "Failed to find the handler";
-        conn.close("Internal error");
+        BMCWEB_LOG_ERROR << "Connection was already closed";
         return;
     }
 
@@ -199,8 +198,7 @@
         return;
     }
 
-    BMCWEB_LOG_DEBUG << "Console web socket path: " << conn.req.target()
-                     << " Console unix FD: " << unixfd << " duped FD: " << fd;
+    BMCWEB_LOG_DEBUG << "Console unix FD: " << unixfd << " duped FD: " << fd;
 
     if (!iter->second->connect(fd))
     {
@@ -209,10 +207,56 @@
     }
 }
 
+inline void
+    processConsoleObject(crow::websocket::Connection& conn,
+                         const std::string& consoleObjPath,
+                         const boost::system::error_code& ec,
+                         const ::dbus::utility::MapperGetObject& objInfo)
+{
+    // Look up the handler
+    auto iter = getConsoleHandlerMap().find(&conn);
+    if (iter == getConsoleHandlerMap().end())
+    {
+        BMCWEB_LOG_ERROR << "Connection was already closed";
+        return;
+    }
+
+    if (ec)
+    {
+        BMCWEB_LOG_WARNING << "getDbusObject() for consoles failed. DBUS error:"
+                           << ec.message();
+        conn.close("getDbusObject() for consoles failed.");
+        return;
+    }
+
+    const auto valueIface = objInfo.begin();
+    if (valueIface == objInfo.end())
+    {
+        BMCWEB_LOG_WARNING << "getDbusObject() returned unexpected size: "
+                           << objInfo.size();
+        conn.close("getDbusObject() returned unexpected size");
+        return;
+    }
+
+    const std::string& consoleService = valueIface->first;
+    BMCWEB_LOG_DEBUG << "Looking up unixFD for Service " << consoleService
+                     << " Path " << consoleObjPath;
+    // Call Connect() method to get the unix FD
+    crow::connections::systemBus->async_method_call(
+        [&conn](const boost::system::error_code& ec1,
+                const sdbusplus::message::unix_fd& unixfd) {
+        connectConsoleSocket(conn, ec1, unixfd);
+        },
+        consoleService, consoleObjPath, "xyz.openbmc_project.Console.Access",
+        "Connect");
+}
+
 // Query consoles from DBUS and find the matching to the
 // rules string.
 inline void onOpen(crow::websocket::Connection& conn)
 {
+    std::string consoleLeaf;
+
     BMCWEB_LOG_DEBUG << "Connection " << &conn << " opened";
 
     if (getConsoleHandlerMap().size() >= maxSessions)
@@ -227,23 +271,34 @@
 
     conn.deferRead();
 
-    // The console id 'default' is used for the console0
-    // We need to change it when we provide full multi-console support.
-    const std::string consolePath = "/xyz/openbmc_project/console/default";
-    const std::string consoleService = "xyz.openbmc_project.Console.default";
+    // Keep old path for backward compatibility
+    if (conn.url().path() == "/console0")
+    {
+        consoleLeaf = "default";
+    }
+    else
+    {
+        // Get the console id from console router path and prepare the console
+        // object path and console service.
+        consoleLeaf = conn.url().segments().back();
+    }
+    std::string consolePath =
+        sdbusplus::message::object_path("/xyz/openbmc_project/console") /
+        consoleLeaf;
 
     BMCWEB_LOG_DEBUG << "Console Object path = " << consolePath
-                     << " service = " << consoleService
-                     << " Request target = " << conn.req.target();
+                     << " Request target = " << conn.url().path();
 
-    // Call Connect() method to get the unix FD
-    crow::connections::systemBus->async_method_call(
-        [&conn](const boost::system::error_code& ec,
-                const sdbusplus::message::unix_fd& unixfd) {
-        connectConsoleSocket(conn, ec, unixfd);
-        },
-        consoleService, consolePath, "xyz.openbmc_project.Console.Access",
-        "Connect");
+    // mapper call lambda
+    constexpr std::array<std::string_view, 1> interfaces = {
+        "xyz.openbmc_project.Console.Access"};
+
+    dbus::utility::getDbusObject(
+        consolePath, interfaces,
+        [&conn, consolePath](const boost::system::error_code& ec,
+                             const ::dbus::utility::MapperGetObject& objInfo) {
+        processConsoleObject(conn, consolePath, ec, objInfo);
+        });
 }
 
 inline void onMessage(crow::websocket::Connection& conn,
@@ -267,6 +322,13 @@
         .onopen(onOpen)
         .onclose(onClose)
         .onmessage(onMessage);
+
+    BMCWEB_ROUTE(app, "/console/<str>")
+        .privileges({{"OpenBMCHostConsole"}})
+        .websocket()
+        .onopen(onOpen)
+        .onclose(onClose)
+        .onmessage(onMessage);
 }
 } // namespace obmc_console
 } // namespace crow
