Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Aug 19, 2017
1 parent a61dcbc commit 9c3500d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/controllers/ContentElementController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use skeeks\cms\models\Tree;
use Yii;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\web\NotFoundHttpException;

/**
Expand Down Expand Up @@ -115,12 +116,26 @@ public function actionView()
$tree = $contentElement->cmsTree;


if ($contentElement->url != "/" . \Yii::$app->request->pathInfo)
if (Url::isRelative($contentElement->url))
{
$url = $contentElement->url;
\Yii::$app->response->redirect($url, 301);
if ($contentElement->url != "/" . \Yii::$app->request->pathInfo)
{
$url = $contentElement->url;
\Yii::$app->response->redirect($url, 301);
}
} else
{
if ($urlData = parse_url($contentElement->url))
{
if (ArrayHelper::getValue($urlData, 'path') != "/" . \Yii::$app->request->pathInfo)
{
$url = $contentElement->url;
\Yii::$app->response->redirect($url, 301);
}
}
}


if ($tree)
{
\Yii::$app->cms->setCurrentTree($tree);
Expand Down

0 comments on commit 9c3500d

Please sign in to comment.