diff --git a/portal-impl/src/com/liferay/portal/servlet/filters/i18n/I18nFilter.java b/portal-impl/src/com/liferay/portal/servlet/filters/i18n/I18nFilter.java
index ca4c2a029a6c31d98273604265506094eb2b64bd..db3118e8a401263caf7a24a8bad1e6c083cd2fcd 100644
--- a/portal-impl/src/com/liferay/portal/servlet/filters/i18n/I18nFilter.java
+++ b/portal-impl/src/com/liferay/portal/servlet/filters/i18n/I18nFilter.java
@@ -130,7 +130,10 @@ public class I18nFilter extends BasePortalFilter {
 		LayoutSet layoutSet = (LayoutSet)request.getAttribute(
 			WebKeys.VIRTUAL_HOST_LAYOUT_SET);
 
-		if (layoutSet != null) {
+		if ((layoutSet != null) &&
+			requestURI.startsWith(
+				PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING)) {
+
 			int[] groupFriendlyURLIndex = PortalUtil.getGroupFriendlyURLIndex(
 				requestURI);
 
@@ -214,15 +217,11 @@ public class I18nFilter extends BasePortalFilter {
 			return LocaleUtil.toLanguageId(PortalUtil.getLocale(request));
 		}
 		else if (prependFriendlyUrlStyle == 3) {
-			Locale locale = LocaleUtil.getDefault();
-
 			if (user != null) {
-				locale = user.getLocale();
-			}
+				HttpSession session = request.getSession();
 
-			HttpSession session = request.getSession();
-
-			session.setAttribute(Globals.LOCALE_KEY, locale);
+				session.setAttribute(Globals.LOCALE_KEY, user.getLocale());
+			}
 
 			return null;
 		}
