1. 程式人生 > >CI3.15框架url去除index.php

CI3.15框架url去除index.php

  1. 開啟apache的配置檔案,conf/httpd.conf : 
    LoadModule rewrite_module modules/mod_rewrite.so
  2. 把該行前的#去掉。 搜尋 AllowOverride None(配置檔案中有多處),看註釋資訊,將相關.htaccess的該行資訊改為: 
    AllowOverride All 
  3. 在CI的根目錄下,即在index.php,system的同級目錄下,建立.htaccess,直接建立該檔名的不會成功,可以先建立記事本檔案,另存為該名的檔案即可。內容如下(CI手冊上也有介紹): 
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /index.php/$1 [L]
    如果不在根目錄下: 
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteRule ^(.*)$ /目錄/index.php/$1 [L]
  4. 重啟apache,完成。