yii index.php隐藏的设置方法

yii index.php隐藏的设置方法,第1张

yii index.php隐藏的设置方法

yii index.php隐藏的设置方法: 首先开启apache的rewrite模块;然后去掉rewrite前的“#”符号;接着建立“.htaccess”文件;最后修改yii的配置文件“mail.php”即可。

yii 隐藏index.php

首先,开启apache的rewrite模块

去掉rewrite前的#,如下所示

    LoadModule rewrite_module modules/mod_rewrite.so

接着,在yii的index.php同级目录建立.htaccess文件,内容如下

    <IfModule mod_rewrite.c>   
    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  
    </IfModule>

最后,在yii的配置文件mail.php 中添加

      '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

推荐学习:《yii教程》

以上就是yii index.php隐藏的设置方法的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/700821.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-23
下一篇 2022-04-23

发表评论

登录后才能评论

评论列表(0条)

保存