function check_m_url($subsite_id, &$smarty, $page_url) { global $_CFG; $current_host = 'http://' . $_SERVER['HTTP_HOST']; //取得当前域名 $current_url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; //判断地址后面部分 $url = $current_host . $current_url; if ($page_url) { if ($current_host != rtrim($page_url, '/')) { if ($_CFG['subsite_method'] == 1) { $url = str_replace($current_host, rtrim($page_url, '/'), $url); redirect301($url); } else { header("HTTP/1.1 404 Not Found"); $smarty->display("404.htm"); exit; } } } else { if ($_CFG['subsite_id'] != $subsite_id) { if ($_CFG['subsite_method'] == 1) { $suburl = get_m_subsiteurl_by_id($subsite_id); $url = str_replace($current_host, rtrim($suburl, '/'), $url); redirect301($url); } else { header("HTTP/1.1 404 Not Found"); $smarty->display("404.htm"); exit; } } } }
public static function parseRequest() { global $_FASTPHP_REWRITE_RULE; $actionkey = self::parseActionKey(); //检查URL是否规范化 if (FastPHP_Request::isGetMethod()) { //仅GET方法才可能跳转 $mode = __REWRITE_RULE_MODE; $config =& $_FASTPHP_REWRITE_RULE[$actionkey]; if (!empty($config['mode'])) { $mode = $config['mode']; } if (!empty($_COOKIE['fastphp_r301_mark'])) { setcookie("fastphp_r301_mark", "", time() - 86400, "/"); } else { if ($mode == "BASIC_R301" || $mode == "PERFECT_R301") { $params = $_GET; if (isset($params['actionkey'])) { unset($params['actionkey']); } $url = RewriteHelper::getURL($actionkey, $params); //die($url); $r301 = false; if (substr($url, 0, 7) == 'http://') { if (strcmp("http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $url) !== 0) { $r301 = true; } } else { if (substr($url, 0, 8) == 'https://') { if (strcmp("https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], $url) !== 0) { $r301 = true; } } else { if (strcmp($_SERVER['REQUEST_URI'], $url) !== 0) { $r301 = true; } } } if ($r301) { setcookie("fastphp_r301_mark", "1", 0, "/"); redirect301($url); } } } } return $actionkey; }