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

            
              

  • 相关阅读:
    洛谷P3799 妖梦拼木棒
    bzoj1008 [HNOI2008]越狱
    洛谷P3414 SAC#1
    洛谷P1078 文化之旅
    bzoj1053 [HAOI2007]反素数ant
    洛谷P1588 丢失的牛
    bzoj1085 [SCOI2005]骑士精神
    noip2016 蚯蚓
    noip2016 换教室
    html笔记03:表单
  • 原文地址:https://www.cnblogs.com/xshang/p/3694638.html
Copyright © 2011-2022 走看看