Rumah  >  Artikel  >  rangka kerja php  >  yii index.php隐藏的设置方法

yii index.php隐藏的设置方法

藏色散人
藏色散人asal
2020-07-04 10:18:113144semak imbas

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

yii index.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 中添加

      &#39;urlManager&#39;=>array(
       &#39;urlFormat&#39;=>&#39;path&#39;,
       &#39;showScriptName&#39;=>false,
       &#39;rules&#39;=>array(
      &#39;<controller:\w+>/<id:\d+>&#39;=>&#39;<controller>/view&#39;,
      &#39;<controller:\w+>/<action:\w+>/<id:\d+>&#39;=>&#39;<controller>/<action>&#39;,
      &#39;<controller:\w+>/<action:\w+>&#39;=>&#39;<controller>/<action>&#39;,
     ),
  ),

  

   这样就隐藏了index.php

推荐学习:《yii教程

Atas ialah kandungan terperinci yii index.php隐藏的设置方法. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:Yii2.0框架怎么下载?Artikel seterusnya:yii怎么引用assets?