yii 隱藏index.php

    首先,開啓apache的rewrite模塊php

    去掉rewrite前的#,以下所示apache

    LoadModule rewrite_module modules/mod_rewrite.soyii

 

    接着,在yii的index.php同級目錄創建.htaccess文件,內容以下url

    <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>spa

 

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

      '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>',
     ),
  ),ip

  

   這樣就隱藏了index.phpit

相關文章
相關標籤/搜索