Home > Backend Development > PHP Tutorial > Yii暗藏index.php文件的步骤

Yii暗藏index.php文件的步骤

WBOY
Release: 2016-06-13 11:59:49
Original
870 people have browsed it

Yii隐藏index.php文件的步骤
作者:zccst

1.修改Apache的配置httpd.conf
      (1)开启apache的mod_rewrite模块去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号
      (2)确保中有“AllowOverride All”
批注:对于wamp而言,第二个AllowOverride All已经开启。
AllowOverride在Apache的配置文件出现三次,但是只有一个地方需要 All,其他两个地方都是None。
      (3)重启Apache

2.在项目中的/protected/config/main.php中添加代码:

    'components'=>array(                ...                'urlManager'=>array(                      'urlFormat'=>'path',                      'showScriptName'=>false,//注意false不要用引号括上                      'urlSuffix'=>'.html',//搭车加上.html后缀,霸道                      'rules'=>array(                          'sites'=>'site/index',                      ),                ),                ...            ),
Copy after login


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
Copy after login

批注:这段在yii的官方指南中也有:
详见:http://www.yiiframework.com/doc/guide/1.1/zh_cn/topics.url

这样就可以实现隐藏index.php入口文件了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template