public override string TransformFriendlyUrlToQueryString(string[] urlParms, int tabId, int portalId, FriendlyUrlOptions options, string cultureCode, DotNetNuke.Entities.Portals.PortalAliasInfo portalAlias, ref List <string> messages, out int status, out string location)
        {
            status   = 200;
            location = null;

            string         result = string.Empty, Slug = string.Empty, PageName = string.Empty;
            PortalSettings pS               = null;
            bool           PageNameRedirect = false;

            urlParms = urlParms.Select(s => s.ToLower()).Distinct().ToArray();
            List <string> urlParmsList = new List <string>(urlParms).ConvertAll(u => u.ToLower());

            int SlugTabID = URLManager.GetSlugTabID(urlParms, ref Slug, tabId, PortalController.Instance.GetPortal(portalId));

            if (SlugTabID != -1) //Slug Found
            {
                URLEntity CurrentURL = URLManager.GetURL(Slug);

                //Redirect if it's not the default URL
                if (CurrentURL != null && !CurrentURL.IsDefault)
                {
                    InitPortalSettings(ref pS, tabId, portalAlias);
                    return(Redirect(out status, out location, portalId, pS, SlugTabID, result, CurrentURL, null));
                }

                if (pS == null)
                {
                    pS = new PortalSettings(tabId, portalAlias);
                }

                //DNN 8580
                //https://dnntracker.atlassian.net/browse/DNN-8580?page=com.googlecode.jira-suite-utilities%3Atransitions-summary-tabpanel
                ClearUrlParams(ref urlParmsList, ref PageName, Slug, SlugTabID, pS);

                //Tab not identified...need redirect
                if (tabId == -1)
                {
                    InitPortalSettings(ref pS, tabId, portalAlias);

                    if (CurrentURL.IgnorePageName)
                    {
                        return(string.Empty);
                    }
                    else
                    {
                        //Redirect based on Include PageName if we're not on homepage
                        if (SlugTabID != pS.HomeTabId && CurrentURL.PageName && !urlParmsList.Contains(PageName) && !string.Join("/", urlParmsList).Contains(PageName))
                        {
                            PageNameRedirect = true;
                        }
                        else if (!CurrentURL.PageName && (urlParmsList.Contains(PageName) || string.Join("/", urlParmsList).Contains(PageName)))
                        {
                            PageNameRedirect = true;
                        }

                        //Remove PageName
                        foreach (var item in PageName.Split('/'))
                        {
                            urlParmsList.Remove(item);
                        }

                        //Setup Rewrite Path
                        result = "?TabId=" + SlugTabID.ToString();
                    }
                }

                string remainder = base.CreateQueryStringFromParameters(urlParmsList.ToArray(), -1);

                string Prefix = urlParmsList.Count % 2 == 0 ? string.Empty : "=";


                if (PageNameRedirect)
                {
                    InitPortalSettings(ref pS, tabId, portalAlias);
                    return(Redirect(out status, out location, portalId, pS, SlugTabID, result, CurrentURL, remainder));
                }


                //Rewrite URL to appropriate page
                if (result.StartsWith("?TabId=") && !string.IsNullOrEmpty(Slug))
                {
                    result += "&" + Slug + remainder;
                }
                else
                {
                    result += Slug + remainder;
                }
            }

            return(result);
        }