当前位置:首页 > 开发 > 编程语言 > PHP > 正文

Yii系列总结:隐藏index.php步骤

发表于: 2013-02-19   作者:dcj3sjt126com   来源:转载   浏览:
yii
摘要: 1.开启apache的mod_rewrite模块     去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号     确保<Directory "..."></Directory>中有“All

1.开启apache的mod_rewrite模块
     去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号
     确保<Directory "..."></Directory>中有“AllowOverride All”
2.在项目中的/protected/config/main.php中添加代码:

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

'components'=>array(

           ...

           'urlManager'=>array(

                 'urlFormat'=>'path',

                 'showScriptName'=>false,//注意false不要用引号括上

           'urlSuffix'=>'.html',

                 'rules'=>array(

                     'sites'=>'site/index',

                 ),

           ),

           ...

       ),

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


3.在与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

Yii系列总结:隐藏index.php步骤

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号