diff --git a/core/server/web/shared/middlewares/custom-redirects.js b/core/server/web/shared/middlewares/custom-redirects.js index 02966000be..5fa3088fd8 100644 --- a/core/server/web/shared/middlewares/custom-redirects.js +++ b/core/server/web/shared/middlewares/custom-redirects.js @@ -53,7 +53,9 @@ _private.registerRoutes = () => { const fromURL = url.parse(req.originalUrl); const toURL = url.parse(redirect.to); - toURL.pathname = fromURL.pathname.replace(new RegExp(redirect.from, options), toURL.pathname), + toURL.pathname = (toURL.hostname) + ? toURL.pathname + : fromURL.pathname.replace(new RegExp(redirect.from, options), toURL.pathname); toURL.search = fromURL.search; res.set({