diff --git a/portal-impl/src/com/liferay/portal/servlet/I18nServlet.java b/portal-impl/src/com/liferay/portal/servlet/I18nServlet.java
index 6928413581a08c6a5de72707133877ef2209affc..071779dde480e4276e3c64bbb7efda2710f2dee7 100644
--- a/portal-impl/src/com/liferay/portal/servlet/I18nServlet.java
+++ b/portal-impl/src/com/liferay/portal/servlet/I18nServlet.java
@@ -161,6 +161,10 @@ public class I18nServlet extends HttpServlet {
 
 		String path = GetterUtil.getString(request.getPathInfo());
 
+		Locale i18nLocale = LocaleUtil.fromLanguageId(i18nLanguageId);
+
+		String i18nPath = StringPool.SLASH + i18nLocale.toLanguageTag();
+
 		if (Validator.isNull(path)) {
 			path = "/";
 		}
@@ -176,6 +180,8 @@ public class I18nServlet extends HttpServlet {
 					PortalInstances.getCompanyId(request), friendlyURL);
 
 				if (siteGroup == null) {
+					request.setAttribute(WebKeys.I18N_ERROR_PATH, i18nPath);
+
 					return null;
 				}
 
@@ -184,10 +190,6 @@ public class I18nServlet extends HttpServlet {
 			}
 		}
 
-		Locale i18nLocale = LocaleUtil.fromLanguageId(i18nLanguageId);
-
-		String i18nPath = StringPool.SLASH + i18nLocale.toLanguageTag();
-
 		if (siteDefaultLocale == null) {
 			if (PropsValues.LOCALE_USE_DEFAULT_IF_NOT_AVAILABLE) {
 				siteDefaultLocale = PortalUtil.getSiteDefaultLocale(siteGroup);