Yii2 Url Management 使用介绍 [ 2.0 版本 ]
Yii2 Url Management 使用介绍
简约简单不说废话直接上代码了
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => '$2y$13$XV1Vbasx6Gib7ujOZwlzq.auFh0BIi.aDekM4TTMQl0bnV1PQAHMK',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
弄完上面的配置文件之后,首先确保 apache 服务器配置好了 Rewrite 规则,Yii2 推荐的apache配置如下可能还要加个.htaccess文件,代码如下
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
好的到此我们的配置就ok了,可以愉快的去看看url的显示!
金色木叶枫 乌鲁木齐
注册时间:2013-07-01
最后登录:2017-10-17
在线时长:62小时10分
最后登录:2017-10-17
在线时长:62小时10分
- 粉丝21
- 金钱8685
- 威望70
- 积分10005
共 0 条评论