本文整理匯總了PHP中Rewrite::applyRules方法的典型用法代碼示例。如果您正苦於以下問題:PHP Rewrite::applyRules方法的具體用法?PHP Rewrite::applyRules怎麽用?PHP Rewrite::applyRules使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Rewrite
的用法示例。
在下文中一共展示了Rewrite::applyRules方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: analyzeUrl
public function analyzeUrl()
{
// Check if URL is set in general
if (is_null($this->url)) {
throw new Exception("No request URL set!");
return;
}
// Check for rewrtite rules
$rewrite = new Rewrite($this->url);
$rewrite->applyRules();
if ($rewrite->getTargetUrl() != $this->url) {
if (!$rewrite->transportQueryParameter()) {
$_GET = array();
$_POST = array();
}
if ($rewrite->isRedirect()) {
$this->redirectToUrl($rewrite->getTargetUrl(), $_POST);
}
$this->setUrl($rewrite->getTargetUrl());
$this->analyzeRequest(!$rewrite->isLastForward());
}
// Check access rights to requested content
$access = new AccessOfficer("content", $this->content_id, $this->session->getUser(), $this->content_parents);
if (!$access->check()) {
// Access denied
if (!$access->getDeniedContentID()) {
// No content to be shown as 403 page set
// TODO set up default 403 (and 404) templates
throw new Exception("Access denied and no denied content defined!");
return;
}
// Should parameters be transported through the redirects / rewrites
if (!$access->transportQueryParameter()) {
$_GET = array();
$_POST = array();
}
// Show 403 error page or redirect if neccessary
$newcontent = new Content($access->getDeniedContentID());
if ($access->isRedirect() && $newcontent->getID() != $this->content_id) {
// Redirect, but keep requested URL as origin parameter
// TODO: keep origin request parameters as well!
$this->redirectToUrl("/" . $newcontent->getUrl() . "?origin=" . $this->url, $_POST);
}
$this->setUrl($newcontent->getUrl());
$this->analyzeRequest(!$access->isLastForward());
}
// TODO: HookPoints to manipulate this behaviour
}