function verify_subdirectory_url($prefix, $scriptid = null) { global $vbulletin; if (!$prefix) { return; } // Never redirect a post // unless we're in debug mode and we wan't to error out on the bad urls // unless again its ajax... we're relying on the old urls for ajax because // a) it doesn't matter, users and search engines one see them and b) getting the // url logic into javascript is difficult. if ('GET' != $_SERVER['REQUEST_METHOD'] and (!(defined('DEV_REDIRECT_404') and DEV_REDIRECT_404) or $vbulletin->GPC['ajax'])) { return; } if (defined('FRIENDLY_URL_LINK')) { $friendly = vB_Friendly_Url::fetchLibrary($vbulletin, FRIENDLY_URL_LINK . '|nosession'); if (vB_Friendly_Url::getMethodUsed() == FRIENDLY_URL_REWRITE) { $scriptid = $friendly->getRewriteSegment(); } else { $scriptid = $friendly->getScript(); } } else { if (is_null($scriptid)) { $scriptid = THIS_SCRIPT; } } $pos = strrpos(VB_URL_CLEAN, '/' . $scriptid); if ($pos === false) { //if we don't know what this url is, then lets not try to mess with it. //this came up with the situation where the main index.php is set to forum //but the forums have been moved to a subdirectory. Doesn't make much sense //but we should handle it gracefully. return; } $base_part = substr(VB_URL_CLEAN, 0, $pos); $script_part = substr(VB_URL_CLEAN, $pos + 1); if (!preg_match('#' . preg_quote($prefix) . '$#', $base_part)) { //force the old urls to 404 for testing purposes if (defined('DEV_REDIRECT_404') and DEV_REDIRECT_404) { //dev only, no need to phrase the error. header("HTTP/1.0 404 Not Found"); standard_error("old style url found, shouldn't get here"); } else { $url = $prefix . '/' . $script_part; // redirect to the correct url exec_header_redirect($url, 301); } } }