/** * check redirect * * @return void */ public function check_redirect() { if ($this->__skip === true) { return; } // check added www in production env if (\Fuel\Core\Fuel::$env === \Fuel\Core\Fuel::PRODUCTION) { if (!preg_match('/^' . \Config::get('seo.subdomain') . '\\./', $_SERVER['HTTP_HOST'])) { $new_uri = \Fuel\Core\Input::protocol() . '://' . \Config::get('seo.subdomain') . '.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; \Fuel\Core\Response::redirect($new_uri, 'location', 301); } } // init $redirect_flg = false; $redirect_uri = $this->_current_uri . $this->_current_get; // reverse routing $check_uri = Route::reverse_route($this->_routed_uri); if ($check_uri !== $this->_routed_uri or $check_uri !== $this->_current_uri) { $redirect_flg = true; $redirect_uri = $check_uri . $this->_current_get; } // page=1 check (301 redirect) if (\Fuel\Core\Input::get('page') === '1') { $redirect_flg = true; $redirect_uri = preg_replace('/[&?](page=1&?)/', '$1', $redirect_uri); } // last &, ? check (301 redirect) if (empty(\Input::get()) and preg_match('/[&\\?]$/', $redirect_uri)) { $redirect_flg = true; $redirect_uri = preg_replace('/[&\\?]$/', '', $redirect_uri); } // do 301 redirect if ($redirect_flg) { \Fuel\Core\Session::keep_flash(); // before redirect, if env is development and posted, set notify if (\Fuel\Core\Fuel::$env === \Fuel\Core\Fuel::DEVELOPMENT and \Fuel\Core\Input::post()) { \Fuel\Core\Session::set_flash('error', 'Redirect occured, please check post url'); } \Fuel\Core\Log::debug($this->_current_uri . $this->_current_get . ': redirect to ' . $redirect_uri); \Fuel\Core\Response::redirect($redirect_uri, 'location', 301); } }