首先我们分步骤来:

安装好 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.然后就成功了,试试吧

yii框架 隐藏index.php 以及美化URL(pathinfo模式访问)的更多相关文章

  1. Yii Framework隐藏index.php文件的步骤

    Yii Framework隐藏index.php文件的步骤 作者:feebas 发布于:2012-4-23 13:36 Monday 分类:Yii Framework 1.开启apache的mod_r ...

  2. CI 框架隐藏index.php-ubuntu

    和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单.但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步 ...

  3. CI 框架 隐藏index.php 入口文件 和 设置访问application下子目录

    1.隐藏根目录下 index.php, 在根目录下创建 .htaccess文件 内容如下: <IfModule mod_rewrite.c> RewriteEngine on Rewrit ...

  4. CodeIgniter框架隐藏index.php

    问题描述:使用CodeIgniter框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.” 原因在于使 ...

  5. ThinkPHP CI codeignitor 框架 apache 重写 url 隐藏index.php 服务器 报错:Object not found! 可能是.htaccess隐藏index.php

    隐藏index.php可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则.以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了该文 ...

  6. Yii框架后续

    关于Yii框架遗留的知识点. 1.url路由方式 (1).问号传参(默认) eg: http://localhost/项目/app/index.php http://localhost/项目/app/ ...

  7. ThinkPHP5 隐藏index.php问题

    隐藏index.php 可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则. 以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了 ...

  8. YII框架安装步骤(yii框架版本1.1.20,时间是2018/11)

    0x01 首先中文官网下载https://www.yiichina.com/download 0x02 解压压缩包到www目录下(方便以后调试) 0x02-1 如果想看一下你的电脑是否能匹配yii框架 ...

  9. yii框架美化访问路径,去掉index.php/?r=部分

    一.找到配置文件(ps:advance高级模板) 在工程目录-> backend目录 或 frontend目录 -> config目录 -> main.php文件 -> 在 r ...

随机推荐

  1. 【java】static用法

    static作用: 用来修饰函数成员,成员变量和成员函数.类对象的属性都一致且能共享,比如国籍,这就能用static修饰,name不能共享,因为每个人都有自己的名字. 特有内容(name)随着对象存储 ...

  2. 量化分析v1

    量化分析v1 # -*- coding: utf-8 -*- """ Created on Wed Apr 11 10:13:32 2018 @author: chens ...

  3. GitExtentions添加SSH证书,pull和push时不必输入密码

    1. 工具-->设置,选择SSH,选择PuTTY 2.  选择 3. 在新打开的页面,可以生成key或者加载已有的key.putty的key是.ppk结尾的特殊格式.关于生成key和在githu ...

  4. EXCEL统计不重复值的数量

    如这一列中,有多少不重复值? 1.可以点击,数据,删除重复项,清除重复值,然后剩下的统计一下即可知道:       ===> 2.用公式:=SUMPRODUCT((MATCH(E3:E20,E3 ...

  5. SpringBoot入门(0) HelloWorld的实现与原理分析

    SpringBoot(0) HelloWorld的实现与原理分析 一.环境准备 1.1 环境约束 –jdk1.8:Spring Boot 推荐jdk1.7及以上:java version “1.8.0 ...

  6. property用法

    用法一 class Test(object): def __init__(self): self.__Num = 100 def setNum(self,Num): print("---se ...

  7. [转][C#]压缩解压

    { internal static class Compressor { public static Stream Decompress(Stream source, bool bidiStream) ...

  8. MFC 中CString 格式16进制转int 十进制

    代码:CString  v_hex ; int v_dec; v_dec = wcstol(v_hex, NULL, 16);

  9. Struts2 xxAction-validation.xml使用

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE validators PUBLIC &quo ...

  10. java.lang.NoClassDefFoundError: org/apache/tomcat/util/res/StringManager

    一个比较老的web项目,  IDEA 导入后不能用,  出现了各种问题, 但是, 别人用eclipse 导入就不会有问题,  我折腾了半天, 还是各种问题,  真是郁闷了.  哎, 承认很难配置吧, ...