# RewriteEngine
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
# Редирект на страницу без многократных /.
RewriteCond %{THE_REQUEST} //
RewriteRule .* /$0 [R=301,L]
# Убираем несколько слешей в урле
RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]
# Убираем последний слеш в урле
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} (/+)$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]
# Редирект со строчных букв на прописные
# Необходимо в VirtualHost добавить RewriteMap lc int:tolower
# RewriteCond %{REQUEST_URI} [A-Z]
# RewriteRule ^(.*)$ /${lc:$1} [R=301,L]
# Блокируем рефер спам
RewriteCond %{HTTP_REFERER} simple-share-buttons\.com [NC]
RewriteRule .* – [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
#в случае index.php|htm|html:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/
RewriteRule ^(.*)index\.(php|html|htm)$ $1/ [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTPS/
RewriteRule ^(.*)index\.(php|html|htm)$ $1/ [R=301,L]
</IfModule>
/**
* Logs in the user using the given username and password in the model.
* @return boolean whether login is successful
*/
public function login($is_front = false)
{
if ($this->_identity === null) {
$this->_identity = new UserIdentity($this->username, $this->password);
$this->_identity->authenticate();
}
if ($this->_identity->errorCode === UserIdentity::ERROR_NONE) {
$duration = $this->rememberMe ? 3600 * 24 * 30 : 0; // 30 days
Yii::app()->user->login($this->_identity, $duration);
return true;
} else
return false;
}
/**
* Функция генерации строки идентификатора компании в таблице Review
* @return boolean
*/
public function getReview_id()
{
return 'company_id_'.$this->id;
}
/**
* Функция получения рейтинга компании
* @return integer
*/
public function getRating()
{
return $this->hasMany(Reviews::className(), ['chan_channel' => 'review_id'])->average('star');
}
$criteria = new CDbCriteria;
$criteria->with=['category']
$criteria->order='category.order_sort ASC';
$model = Products::model()->findAll($criteria);
$qwe = 'Вася';
$script = "
$.ajax({
type: 'GET',
url: '............',
data: { id: ".$qwe ."},
});
";
$this->registerJs($script, yii\web\View::POS_READY);
$qwe = Contacts::findAll(['my_id' => 1]);
$contacts = $qwe->getUser()->all();