首先我们分步骤来:

安装好 yii 以后  我们看到的url地址如下所示:

http://www.3w.com/MyApp/backend/web/index.php?r=site%2Flogin

我们首先去掉 index.php

1.去apache配置中开启rewirte模块

2.配置好我们的虚拟主机  必须开启外部重写规则:

3.在下面的目录下 创建   .htaccess  文件

4.     .htaccess文件里内容如下:

 
  1. <code class="language-php"><span style="font-size:18px;"><strong>Options +FollowSymLinks
  2. IndexIgnore */*
  3. RewriteEngine on
  4. # if a directory or a file exists, use it directly
  5. RewriteCond %{REQUEST_FILENAME} !-f
  6. RewriteCond %{REQUEST_FILENAME} !-d
  7. # otherwise forward it to index.php
  8. RewriteRule . index.php  </strong></span></code>
  1.  
    Options +FollowSymLinks
  2.  
    IndexIgnore */*
  3.  
    RewriteEngine on
  4.  
     
  5.  
    # if a directory or a file exists, use it directly
  6.  
    RewriteCond %{REQUEST_FILENAME} !-f
  7.  
    RewriteCond %{REQUEST_FILENAME} !-d
  8.  
     
  9.  
    # otherwise forward it to index.php
  10.  
    RewriteRule . index.php

5.现在再次在浏览器  访问我们的项目 我们就可以去掉index.php    url  如下:

http://www.3w.com/MyApp/backend/web/?r=site%2Flogin

然后我们 美化 url 如下:

http://www.yii2.com/site/index.html

我们只需要在config目录下配置即可:

2.添加如下代码:

  1.  
    'urlManager' => [
  2.  
    'enablePrettyUrl' => true,//开启url美化
  3.  
    'showScriptName' => false,//隐藏index.php
  4.  
    'suffix' => '.html',//后缀
  5.  
    ],

3.然后就成功了,试试吧

最新文章

  1. JS 数字,金额 用逗号 隔开(数字格式化)
  2. Java编译器如何生成重载和覆盖方法代码
  3. 【NOIP训练】【数论】超级计算机
  4. Android线程池(二)
  5. B - Plane of Tanks: Pro
  6. stack例子
  7. 江中微型统计分析软件V1.0版本完成
  8. expect set timeout -1 永不超时
  9. 使用Common.Logging与log4net的组件版本兼容问题
  10. ASP.NET MVC4通过UrlRewriter配置伪静态,支持html后缀
  11. 学习day02
  12. CSS3 移动端 1PX 线变成0.5PX
  13. 【BZOJ4032】[HEOI2015]最短不公共子串(后缀自动机,序列自动机)
  14. 嵌入式linux——说明(零)
  15. 055、创建macvlan网络 (2019-03-22 周五)
  16. Linux 驱动开发
  17. SpringBoot的学习【2.分析HelloWorld的依赖】
  18. linux、centos下安装配置vim
  19. 怎样从外网访问内网Node.js?
  20. 【摘】50个jQuery代码段帮助你成为一个更好的JavaScript开发者

热门文章

  1. 浏览器调试动态js脚本
  2. Windows和Linux查看端口占用
  3. 通过WebClient模拟post上传文件到服务器
  4. BZOJ 2173 luoguo P4451 [国家集训队]整数的lqp拆分
  5. 如何在ORACLE中查询某一用户下所有的空表
  6. 学习node.js 第2篇 介绍node.js 安装
  7. SSH登录启用Google二次身份验证
  8. 1011 A+B 和 C (15 分)
  9. PHP和Redis实现在高并发下的抢购及秒杀功能示例详解
  10. Android TextView 跑马灯效果 - 2018年6月19日