Yii2 网址重写

来源:互联网 发布:锁骨链一套淘宝 编辑:程序博客网 时间:2024/06/05 17:16

.hacess

<IfModule rewrite_module>      Options +FollowSymLinks      IndexIgnore */*      RewriteEngine On          RewriteCond %{REQUEST_FILENAME} !-f      RewriteCond %{REQUEST_FILENAME} !-d      RewriteRule . index.php  </IfModule>


use yii\helpers\Url;

首页  $relativeHomeUrl = Url::home(); 相对  $absoluteHomeUrl = Url::home(true); 绝对  $httpsAbsoluteHomeUrl = Url::home('https'); 指定协议绝对  

创建网址

$relativeHomeUrl Url::home();$absoluteHomeUrl Url::home(true);$httpsAbsoluteHomeUrl Url::home('https');

echo Url::toRoute(['site/index''src' => 'ref1''#' => 'name']);
echo Url::toRoute('site/index'true);
echo Url::to(['site/index''src' => 'ref1''#' => 'name']);
echo Url::current(); //需要 Yii版本 2.0.3
记忆网址  echo Url::remember();  echo Url::previous();  Url::remember(['product/view', 'id' => 42], 'product');  echo Url::previous('product');  
0 0