首頁  >  文章  >  php框架  >  yii index.php隱藏的設定方法

yii index.php隱藏的設定方法

藏色散人
藏色散人原創
2020-07-04 10:18:113173瀏覽

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教程

以上是yii index.php隱藏的設定方法的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn