Yii2.0使用教程(四)

2025-04-19 18:44:40

1、勃谧锵疙访问Url优化以首页链接为例:http://c.com/index.php?r=site%2Findexa、打开/front髫潋啜缅end/config/main.php中的components下面添加代码,主要是开启apache-rewrite,代码如下:'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'suffix'=>'.html', 'rules' => [ ], ],b、在/frontend/web/目录下编写一个.htaccess 文件,内容如下:<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php [QSA,PT,L]</IfModule>c、访问就可以如此,首页链接就变成:http://c.com/site/index.html

Yii2.0使用教程(四)
Yii2.0使用教程(四)
Yii2.0使用教程(四)
Yii2.0使用教程(四)

2、静漤逗庞俄态资源配置a、在/frontend/web中创建statics文件夹作为frontend的前端茹霭庖褙资源文件b、在statics目录下创建3个文件夹,css、js、images,存放css文件,js文件,和图片。c、打开/frontend/assets/AppAsset.php 修改内容如下:修改其中css/site.css更改为statics/css/site.css(js依此类推)

Yii2.0使用教程(四)
Yii2.0使用教程(四)
Yii2.0使用教程(四)
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢