zoukankan      html  css  js  c++  java
  • Yii隐藏单入口

             Yii进入项目首页时默认是index.php文件路径,如何把index.php去掉,方法如下:

             打开apache配置文件http.conf,找到如下的代码:

             #LoadModule rewrite_module modules/mod_rewrite.so

              把前面的#号去掉。

              往下继续查找,找到<Directory "d:/wamp/www/">,即服务器所在的目录,

               AllowOverride all

               AllowOverride 后面改为all,如上所示。

               重启apache.

               --------------------------------------------------------------------------------------

               打开Yii项目下的配置文件config/main.php,找到

               /*
                 'urlManager'=>array(
                 'urlFormat'=>'path',
                 'rules'=>array(
                '<controller:w+>/<id:d+>'=>'<controller>/view',
                '<controller:w+>/<action:w+>/<id:d+>'=>'<controller>/<action>',
                '<controller:w+>/<action:w+>'=>'<controller>/<action>',
                ),
               ),
               */ 

               把注释去掉,改成

                'urlManager'=>array(
                 'urlFormat'=>'path',

                 'showScriptname'=>false,
                 'rules'=>array(
                '<controller:w+>/<id:d+>'=>'<controller>/view',
                '<controller:w+>/<action:w+>/<id:d+>'=>'<controller>/<action>',
                '<controller:w+>/<action:w+>'=>'<controller>/<action>',
                ),

               ),

             -------------------------------------------------------------------------------------

              最后,在index.php同级目录下添加.htaccess文件:

              Options +FollowSymLinks

              IndexIgnore */*

             RewriteEngine on

             # if a directory or a file exists, use it directly

             RewriteCond %{REQUEST_FILENAME} !-f

             RewriteCond %{REQUEST_FILENAME} !-d

             # otherwise forward it to index.php

             RewriteRule . index.php

            
              

  • 相关阅读:
    Java中字符串的学习(四)基本数据类型包装类的学习与使用
    Java中字符串的学习(三)StringBuffer与StringBuilder
    Java中字符串的学习(二)String类的小练习
    Java中字符串的学习(一)String类的概述及常见方法使用
    ios开发之解决重用TableViewCell导致的界面错乱的问题
    SpringBoot+Redis形成数据 缓存
    SpringBoot logback slf4j 的理解和使用
    Sring IOC的用途和理解
    SpringBoot AOP 理解和用途
    centos 安装遇到的问题
  • 原文地址:https://www.cnblogs.com/xshang/p/3694638.html
Copyright © 2011-2022 走看看