public static function updateShurls() { $sefConfig =& shRouter::shGetConfig(); // set the short link tag $shPageInfo =& shRouter::shPageInfo(); $shPageInfo->shURL = ''; if ($sefConfig->enablePageId && !$sefConfig->stopCreatingShurls) { try { jimport('joomla.utilities.string'); $nonSefUrl = JString::ltrim($shPageInfo->shCurrentPageNonSef, '/'); $nonSefUrl = shSortURL($nonSefUrl); // remove tracking vars (Google Analytics) $nonSefUrl = Sh404sefHelperGeneral::stripTrackingVarsFromNonSef($nonSefUrl); // try to get the current shURL, if any $shURL = Sh404sefHelperDb::selectResult('#__sh404sef_pageids', array('pageid'), array('newurl' => $nonSefUrl)); // if none, we may have to create one if (empty($shURL)) { $shURL = self::_createShurl($nonSefUrl); } // insert in head and header, if not empty if (!empty($shURL)) { $fullShURL = JString::ltrim($GLOBALS['shConfigLiveSite'], '/') . '/' . $shURL; $document =& JFactory::getDocument(); if ($sefConfig->insertShortlinkTag) { $document->addHeadLink($fullShURL, 'shortlink'); // also add header, especially for HEAD requests JResponse::setHeader('Link', '<' . $fullShURL . '>; rel=shortlink', true); } if ($sefConfig->insertRevCanTag) { $document->addHeadLink($fullShURL, 'canonical', 'rev', array('type' => 'text/html')); } if ($sefConfig->insertAltShorterTag) { $document->addHeadLink($fullShURL, 'alternate shorter'); } // store for reuse $shPageInfo->shURL = $shURL; } } catch (Sh404sefExceptionDefault $e) { } } }
function revert(&$url_array, $pos) { $sefConfig =& shRouter::shGetConfig(); // get DB $database =& JFactory::getDBO(); $QUERY_STRING = ''; $req = implode('/', $url_array); if ($req != '/') { $req = JString::ltrim($req, '/'); } // V x $req = str_replace("//", "/", $req); _log('sef404 reverting URL : ' . $req); // read from db $sql = "SELECT oldurl, newurl FROM #__redirection WHERE oldurl = " . $database->Quote($req) . " ORDER BY rank ASC LIMIT 1"; // V 1.2.4.q $database->setQuery($sql); $row = $database->loadObject(); if ($row) { // use the cached url $string = $row->newurl; // check for urls using wrong letter case, 301 redirect to correct url case $shPageInfo =& shRouter::shPageInfo(); if (empty($shPageInfo->autoRedirectsDisabled) && $sefConfig->redirectToCorrectCaseUrl) { // if initial query exactly matches oldurl found in db, then case is correct // else we redirect to the url found in db, but we also need to append query string to it ! if ($req != $row->oldurl) { // can only be different from case // what is the url we should redirect to ? $targetUrl = str_replace($req, $row->oldurl, $shPageInfo->shSaveRequestURI); $targetUrl = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $targetUrl . (empty($shPageInfo->URI->anchor) ? '' : '#' . $shPageInfo->URI->anchor); // perform redirect _log('Redirecting to correct url case : from ' . $req . ' to ' . $targetUrl); shRedirect($targetUrl); } } // keep going if we did not redirect to correct case _log('sef404 reverting URL : found : ' . $row->newurl); // update the count $database->setQuery("UPDATE #__redirection SET cpt=(cpt+1) WHERE `newurl` = " . $database->Quote($row->newurl) . " AND `oldurl` = " . $database->Quote($row->oldurl)); // V 1.2.4.q $database->query(); // now we must merge query string from request and POST data with that found in db // as there might be common variables. For instance, limit=5 in the DB // but limit=10 as been pass as POST DATA from a drop-down list item $otherVars = empty($shPageInfo->URI->querystring) ? array() : $shPageInfo->URI->querystring; $postVars = JRequest::get('post'); $otherVars = array_merge($otherVars, $postVars); if (!empty($otherVars)) { foreach ($otherVars as $key => $value) { // if var exists in the incoming url, override it with querystring or post var value if (shGetURLVar($string, $key, null) !== null) { // if we change the value of limit, we must reset limitstart, or we may end up // with weird page number if ($key == 'limit') { $limit = shGetURLVar($string, 'limit', null); if (!is_null($limit) && $value != $limit) { // we are changing limit value : is there a limitstart ? $limitstart = shGetURLVar($string, 'limitstart', null); if (!is_null($limitstart)) { // calculate a new limitstart $limitstart = empty($limit) ? 0 : floor($limitstart / $limit) - 1; $limitstart = $limitstart < 0 ? 0 : $limitstart; // and set it $string = shSetURLVar($string, 'limitstart', $limitstart, $canBeEmpty = true); // kill any remaining limitstart value if (array_key_exists('limitstart', $otherVars)) { unset($otherVars['limitstart']); } } } } // now apply new value for the key $string = shSetURLVar($string, $key, $value); } } } $string = str_replace('&', '&', $string); $QUERY_STRING = str_replace('index.php?', '', $string); // so weird : because of how Joomla choose to not include $limit in urls, I must remove &limit=xx from the restored url // I do have to store it in db however, otherwise same sef will be associated with same non-sef, and then // Joomla content views will be screwed up also as they guess $limit and reset JRequest('limit'); if (!empty($QUERY_STRING)) { $QUERY_STRING = '&' . $QUERY_STRING; $option = shGetURLVar($QUERY_STRING, 'option'); $layout = shGetURLVar($QUERY_STRING, 'layout'); if (empty($layout)) { $layout = 'default'; } $view = shGetURLVar($QUERY_STRING, 'view'); if ($option == 'com_content' && $layout != 'blog' && ($view == 'category' || $view == 'section')) { $limit = shGetURLVar($QUERY_STRING, 'limit'); //$QUERY_STRING = shCleanUpVar( $QUERY_STRING, 'limit'); // but we need to keep it, because of a bug in Joomla, which I could not trace // whereby the user state limit value in com_content.default.limit is that of the blog instead of that of the current view global $mainframe; $mainframe->setUserState('com_content.sh.' . $view . '.' . $layout . '.limit', $limit); //_log( 'Removing limit from reverted url, to : ' . $QUERY_STRING); } $QUERY_STRING = JString::ltrim($QUERY_STRING, '&'); } } return $QUERY_STRING; }
function shCheckVMCookieRedirect() { $shPageInfo =& shRouter::shPageInfo(); if (shIsSearchEngine() && strpos($shPageInfo->shCurrentPageURL, 'vmchk/') !== false) { shRedirect(str_replace('vmchk/', '', $shPageInfo->shCurrentPageURL)); } }
function _buildSefRoute(&$uri) { $sefConfig =& shRouter::shGetConfig(); $shPageInfo =& shRouter::shPageInfo(); $menu =& shRouter::shGetMenu(); // keep a copy of Joomla original URI, which has article names in it (ie: 43:article-title) $originalUri = clone $uri; shNormalizeNonSefUri($uri, $menu); shNormalizeNonSefUri($originalUri, $menu, $removeSlugs = false); // do our job! $query = $uri->getQuery(false); $route = shSefRelToAbs('index.php?' . $query, null, $uri, $originalUri); $route = ltrim(str_replace($GLOBALS['shConfigLiveSite'], '', $route), '/'); $route = $shPageInfo->base . ($route == '/' ? '' : $route); // find path if (strpos($route, '?') !== false) { $parts = explode('?', $route); if ($sefConfig->shRewriteMode == 2) { // '/index.php?/' // need to extract the first part of the query, which is actually the path // and store it as the path $tmpParts = explode('/index.php?/', $route); $tmpPath = ''; if (isset($tmpParts[1])) { // there is somethings after the /index.php?/ if (strpos($tmpParts[1], '?') !== false) { // but this can also have parameters, so only get the path $tmpPathParts = explode('?', $tmpParts[1]); $tmpPath = $tmpPathParts[0]; } else { $tmpPath = $tmpParts[1]; } } $path = $tmpParts[0] . '/index.php?/' . $tmpPath; } else { // there are some query vars, just use the path $path = $parts[0]; } } else { $path = $route; } $uri->setPath($path); }
function shDoTitleTags(&$buffer) { // Replace TITLE and DESCRIPTION and KEYWORDS if (empty($buffer)) { return; } global $shCustomTitleTag, $shCustomDescriptionTag, $shCustomKeywordsTag, $shCustomRobotsTag, $shCustomLangTag, $shHomeLink, $shMosConfig_lang, $shMosConfig_locale; $database =& JFactory::getDBO(); $sefConfig =& shRouter::shGetConfig(); $shPageInfo =& shRouter::shPageInfo(); // get page details gathered by system plugin // V 1.2.4.t protect against error if using shCustomtags without sh404SEF activated // this should not happen, so we simply do nothing if (!isset($sefConfig) || empty($shPageInfo->shCurrentPageNonSef)) { return; } // fix bug in Joomla search //$shUri = null; //$shOriginalUri = null; //$buffer = str_replace( 'action="index.php"', 'action="'.shSefRelToabs('index.php', '', $shUri, $shUri, $shOriginalUri).'"', $buffer); // check if there is a manually created set of tags from tags file // need to get them from DB if ($sefConfig->shMetaManagementActivated) { // plugin system to automatically build title and description tags on a component per component basis $option = JRequest::getVar('option'); $shDoNotOverride = in_array(str_replace('com_', '', $option), $sefConfig->shDoNotOverrideOwnSef); if (file_exists(sh404SEF_ABS_PATH . 'components/' . $option . '/meta_ext/' . $option . '.php') && ($shDoNotOverride || !$shDoNotOverride && !file_exists(sh404SEF_ABS_PATH . 'components/com_sh404sef/meta_ext/' . $option . '.php'))) { _log('Loading component own meta plugin'); // Load the plug-in file include sh404SEF_ABS_PATH . 'components/' . $option . '/meta_ext/' . $option . '.php'; } else { if (file_exists(sh404SEF_ABS_PATH . 'components/com_sh404sef/meta_ext/' . $option . '.php')) { _log('Loading built-in meta plugin'); include sh404SEF_ABS_PATH . 'components/com_sh404sef/meta_ext/' . $option . '.php'; } } // is this homepage ? set flag for future use $isHome = shSortUrl($shPageInfo->shCurrentPageNonSef) == shCleanUpAnchor($shHomeLink); // now read manually setup tags if ($isHome) { // V 1.2.4.t homepage custom tags $sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = \'' . sh404SEF_HOMEPAGE_CODE . '\''; } else { // V 1.2.4.t make sure we have lang info and properly sorted params if (!preg_match('/(&|\\?)lang=[a-zA-Z]{2,3}/iU', $shPageInfo->shCurrentPageNonSef)) { // no lang string, let's add default $shTemp = explode('-', $GLOBALS['shMosConfig_locale']); $shLangTemp = $shTemp[0] ? $shTemp[0] : 'en'; $shPageInfo->shCurrentPageNonSef .= '&lang=' . $shLangTemp; } $shPageInfo->shCurrentPageNonSef = shSortUrl($shPageInfo->shCurrentPageNonSef); $sql = 'SELECT id, metadesc, metakey, metatitle, metalang, metarobots FROM #__sh404SEF_meta WHERE newurl = \'' . ltrim($shPageInfo->shCurrentPageNonSef, '/') . '\''; } $shCustomTags = null; $database->setQuery($sql); $shCustomTags = $database->loadObject(); if (!empty($shCustomTags)) { $shCustomTitleTag = !empty($shCustomTags->metatitle) ? $shCustomTags->metatitle : $shCustomTitleTag; $shCustomDescriptionTag = !empty($shCustomTags->metadesc) ? $shCustomTags->metadesc : $shCustomDescriptionTag; $shCustomKeywordsTag = !empty($shCustomTags->metakey) ? $shCustomTags->metakey : $shCustomKeywordsTag; $shCustomRobotsTag = !empty($shCustomTags->metarobots) ? $shCustomTags->metarobots : $shCustomRobotsTag; $shCustomLangTag = !empty($shCustomTags->metalang) ? $shCustomTags->metalang : $shCustomLangTag; } // then insert them in page if (empty($shCustomTitleTag)) { $document =& JFactory::getDocument(); $shCustomTitleTag = $document->getTitle(); } if (!empty($shCustomTitleTag)) { $prepend = $isHome ? '' : $sefConfig->prependToPageTitle; $append = $isHome ? '' : $sefConfig->appendToPageTitle; $buffer = preg_replace('/\\<\\s*title\\s*\\>.*\\<\\s*\\/title\\s*\\>/isU', '<title>' . shCleanUpTitle($prepend . $shCustomTitleTag . $append) . '</title>', $buffer); $buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"title.*\\/\\>/isU', '', $buffer); // remove Joomla title meta } if (!is_null($shCustomDescriptionTag)) { $buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"description.*\\/\\>/isU', '<meta name="description" content="' . shCleanUpDesc($shCustomDescriptionTag) . '" />', $buffer); } if (!is_null($shCustomKeywordsTag)) { $buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"keywords.*\\/\\>/isU', '<meta name="keywords" content="' . shCleanUpDesc($shCustomKeywordsTag) . '" />', $buffer); } if (!is_null($shCustomRobotsTag)) { if (strpos($buffer, '<meta name="robots" content="') !== false) { $buffer = preg_replace('/\\<\\s*meta\\s+name\\s*=\\s*"robots.*\\/\\>/isU', '<meta name="robots" content="' . $shCustomRobotsTag . '" />', $buffer); } else { if (!empty($shCustomRobotsTag)) { $buffer = shInsertCustomTagInBuffer($buffer, '</head>', 'before', '<meta name="robots" content="' . $shCustomRobotsTag . '" />', 'first'); } } } if (!is_null($shCustomLangTag)) { $shLang = $shCustomLangTag; if (strpos($buffer, '<meta http-equiv="Content-Language"') !== false) { $buffer = preg_replace('/\\<\\s*meta\\s+http-equiv\\s*=\\s*"Content-Language".*\\/\\>/isU', '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />', $buffer); } else { $buffer = shInsertCustomTagInBuffer($buffer, '</head>', 'before', '<meta http-equiv="Content-Language" content="' . $shCustomLangTag . '" />', 'first'); } } // remove Generator tag if ($sefConfig->shRemoveGeneratorTag) { $buffer = preg_replace('/<meta\\s*name="Generator"\\s*content=".*\\/>/isU', '', $buffer); } // version x : add title to read on link if ($sefConfig->shInsertReadMorePageTitle) { if (strpos($buffer, 'class="readon"') !== false) { $buffer = preg_replace_callback('/<td class="contentheading" width="100%">(.*)class="readon">(.*)<\\/a>/isU', 'shDoLinkReadMoreCallback', $buffer); } } // put <h1> tags around content elements titles if ($sefConfig->shPutH1Tags) { if (strpos($buffer, 'class="componentheading') !== false) { $buffer = preg_replace('/<div class="componentheading([^>]*)>\\s*(.*)\\s*<\\/div>/isU', '<div class="componentheading$1><h1>$2</h1></div>', $buffer); $buffer = preg_replace('/<td class="contentheading([^>]*)>\\s*(.*)\\s*<\\/td>/isU', '<td class="contentheading$1><h2>$2</h2></td>', $buffer); } else { // replace contentheading by h1 $buffer = preg_replace('/<td class="contentheading([^>]*)>\\s*(.*)\\s*<\\/td>/isU', '<td class="contentheading$1><h1>$2</h1></td>', $buffer); } } // version x : if multiple h1 headings, replace them by h2 if ($sefConfig->shMultipleH1ToH2 && substr_count(JString::strtolower($buffer), '<h1>') > 1) { $buffer = str_replace('<h1>', '<h2>', $buffer); $buffer = str_replace('<H1>', '<h2>', $buffer); $buffer = str_replace('</h1>', '</h2>', $buffer); $buffer = str_replace('</H1>', '</h2>', $buffer); } // V 1.3.1 : replace outbounds links by internal redirects if (sh404SEF_REDIRECT_OUTBOUND_LINKS) { $buffer = preg_replace_callback('/<\\s*a\\s*href\\s*=\\s*"(.*)"/isU', 'shDoRedirectOutboundLinksCallback', $buffer); } // V 1.3.1 : add symbol to outbounds links if ($sefConfig->shInsertOutboundLinksImage) { $buffer = preg_replace_callback("/<\\s*a\\s*href\\s*=\\s*(\"|').*(\"|')\\s*>.*<\\/a>/isU", 'shDoInsertOutboundLinksImageCallback', $buffer); } // fix homepage link when using Joomfish in non default languages, error in joomla mainmenu helper if (sh404SEF_PROTECT_AGAINST_BAD_NON_DEFAULT_LANGUAGE_MENU_HOMELINK && !shIsDefaultLang($shMosConfig_locale)) { $badHomeLink = preg_quote(JURI::base()); $targetLang = explode('-', $shMosConfig_locale); $goodHomeLink = JURI::base() . $targetLang[0] . '/'; $buffer = preg_replace('#<div class="module_menu(.*)href="' . $badHomeLink . '"#isU', '<div class="module_menu$1href="' . $goodHomeLink . '"', $buffer); } // insert pageId if tag found, except if editing item on frontend if (strpos($buffer, '{sh404sef_pageid}') !== false) { // pull out contents of editor to prevent URL changes inside edit area $editor =& JFactory::getEditor(); $regex = '#' . $editor->_tagForSEF['start'] . '(.*)' . $editor->_tagForSEF['end'] . '#Us'; preg_match_all($regex, $buffer, $editContents, PREG_PATTERN_ORDER); // create an array to hold the placeholder text (in case there are more than one editor areas) $placeholders = array(); for ($i = 0; $i < count($editContents[0]); $i++) { $placeholders[] = $editor->_tagForSEF['start'] . $i . $editor->_tagForSEF['end']; } // replace editor contents with placeholder text $buffer = str_replace($editContents[0], $placeholders, $buffer); // fetch pageId for current page and replace $sql = 'SELECT pageid FROM #__sh404sef_pageids WHERE newurl = \'' . ltrim($shPageInfo->shCurrentPageNonSef, '/') . '\''; $database->setQuery($sql); $pageId = $database->loadResult(); $buffer = str_replace('{sh404sef_pageid}', $pageId, $buffer); // restore the editor contents $buffer = str_replace($placeholders, $editContents[0], $buffer); } // all done return $buffer; } }
function shDoHeadersChanges() { global $shCanonicalTag; $sefConfig =& shRouter::shGetConfig(); $shPageInfo =& shRouter::shPageInfo(); // get page details gathered by system plugin if (!isset($sefConfig) || empty($sefConfig->shMetaManagementActivated) || empty($shPageInfo->shCurrentPageNonSef)) { return; } // include plugin to build canonical if needed shIncludeMetaPlugin(); // issue headers for canonical if (!empty($shCanonicalTag)) { jimport('joomla.utilities.string'); $link = JURI::root(false, '') . JString::ltrim($shCanonicalTag, '/'); JResponse::setHeader('Link', '<' . $link . '>; rel="canonical"'); } }
} else { // there is a page break, but no title. Use a page number $pattern = str_replace($sefConfig->pagerep, ' ', $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]); $shPageTitle = str_replace('%s', $limitstart + 1, $pattern); } } } } } if (!empty($shPageTitle)) { // found a heading, we should use that as a Title $title[] = shCleanUpTitle($shPageTitle); } } else { if (!empty($limit) && !empty($limitstart)) { $shPageInfo =& shRouter::shPageInfo(); $shLimit = $layout == 'blog' ? shGetDefaultDisplayNumFromConfig($shPageInfo->shCurrentPageNonSef, $includeBlogLinks = $view == 'section') : $limit; $pagenum = empty($limit) ? (int) $limitstart : (int) ($limitstart / $shLimit) + 1; if ($sefConfig->alwaysAppendItemsPerPage) { $shMultPageLength = $sefConfig->pagerep . $shLimit; } else { $shMultPageLength = ''; } $pattern = str_replace($sefConfig->pagerep, ' ', $sefConfig->pageTexts[$GLOBALS['shMosConfig_locale']]); $pageNumber = str_replace('%s', $pagenum, $pattern) . $shMultPageLength; } else { if (!empty($limitstart)) { // this may be a blog category view, with more than one page if ($title[count($title) - 1] == '/') { // need to remove trailing slash added by getContentTitle unset($title[count($title) - 1]);
/** * Apply a method to put the most appropriate urls * at top of list * * @param array $urls an array of retrieved urls * @return array same array, sorted to have most relevant url at offset 0, 1, etc */ function shRankSimilarUrlsSimilarText($urls, $searchedPath) { if (empty($urls)) { return $urls; } // sort by distance // first get current sef url $shPageInfo =& shRouter::shPageInfo(); // current path $path = JString::trim($searchedPath); $path = JString::trim($path, '.'); // create a temporary array indexed ondistance // between the lenght of the request and the current similar url $tmp = array(); foreach ($urls as $url) { $r = null; $distance = similar_text($url->oldurl, $path, $r); $t = array('distance' => $r, 'url' => $url); $tmp[] = $t; } // sort this array according to text similarity usort($tmp, 'shSortByReverseDistance'); // recreate the array we want $rankedUrls = array(); foreach ($tmp as $u) { $rankedUrls[] = $u['url']; } return $rankedUrls; }
if (!empty($shPageInfo->URI->host) && strpos($GLOBALS['shConfigLiveSite'], $shPageInfo->URI->host) === false && strpos($sefConfig->shConfig_live_secure_site, $shPageInfo->URI->host) === false) { _log('Redirecting to home : host don\'t match our config : ' . $GLOBALS['shConfigLiveSite'] . ' | ' . $shPageInfo->URI->host . ' | ' . $sefConfig->shConfig_live_secure_site); shRedirect($GLOBALS['shConfigLiveSite']); } else { $shPageInfo->shCurrentPagePath = $shPageInfo->URI->protocol . '://' . $shPageInfo->URI->host . (!sh404SEF_USE_NON_STANDARD_PORT || empty($shPageInfo->URI->port) ? '' : ':' . $shPageInfo->URI->port) . $shPageInfo->URI->path; $shPageInfo->shCurrentPagePath = shUrlDecode($shPageInfo->shCurrentPagePath); $shPageInfo->shCurrentPagePath = str_replace($GLOBALS['shConfigLiveSite'], '', $shPageInfo->shCurrentPagePath); _log('Current page path : ' . $shPageInfo->shCurrentPagePath); $qString = $shPageInfo->URI->getQueryString(); $shPageInfo->shCurrentPageURL = empty($qString) ? $shPageInfo->shCurrentPagePath : $shPageInfo->shCurrentPagePath . '?' . JString::ltrim($qString, '&'); $rewriteBit = empty($sefConfig->shRewriteMode) ? '' : JString::rtrim($sefConfig->shRewriteStrings[$sefConfig->shRewriteMode], '/'); $shPageInfo->baseUrl = $GLOBALS['shConfigLiveSite'] . $rewriteBit . $shPageInfo->shCurrentPagePath; _log('Current base url : ' . $shPageInfo->baseUrl); // V 1.2.4.s PR2 : workaround for Virtuemart cookie check issue // see second part in shSef404.php if (shIsSearchEngine()) { // simulate doing successfull cookie check _log('Setting VMCHECK cookie for search engine'); $_COOKIE['VMCHECK'] = 'OK'; $_REQUEST['vmcchk'] = 1; // from VM 1.1.2 onward, result is stored in session, not cookie $_SESSION['VMCHECK'] = 'OK'; } } } else { JError::RaiseError(COM_SH404SEF_NOREAD . "( {$sef404} )<br />" . COM_SH404SEF_CHK_PERMS); } } // save page info shRouter::shPageInfo($shPageInfo); }
function _buildSefRoute(&$uri) { $sefConfig =& shRouter::shGetConfig(); $shPageInfo =& shRouter::shPageInfo(); $menu =& shRouter::shGetMenu(); // keep a copy of Joomla original URI, which has article names in it (ie: 43:article-title) $originalUri = clone $uri; shNormalizeNonSefUri($uri, $menu); shNormalizeNonSefUri($originalUri, $menu, $removeSlugs = false); // do our job! $query = $uri->getQuery(false); $route = shSefRelToAbs('index.php?' . $query, null, $uri, $originalUri); $route = ltrim(str_replace($GLOBALS['shConfigLiveSite'], '', $route), '/'); $route = $shPageInfo->base . ($route == '/' ? '' : $route); // find path if (strpos($route, '?') !== false) { $parts = explode('?', $route); $path = $parts[0]; } else { $path = $route; } $uri->setPath($path); }