1. 程式人生 > >CI框架學習之--隱藏入口檔案-index.php

CI框架學習之--隱藏入口檔案-index.php

一般CI框架第一次使用時:

原地址為: 
http://127.0.0.1/CI/index.php/hello/index 
隱藏入口檔案後只需要把地址寫成即可: 
http://127.0.0.1/CI/hello/index

1、需要開啟Apache的 rewrite 功能 Apache2.2\conf\httpd.conf 修改如下:

修改前:
     #LoadModule rewrite_module modules/mod_rewrite.so

        ...
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit

        AllowOverride None

修改成:
    # 搜尋 mod_rewrite 與 .htaccess 關鍵字來進行查詢修改項
        LoadModule rewrite_module modules/mod_rewrite.so

        <Directory "E:/ComTu_Design/PHP/Apache2.2/htdocs">
            Options Indexes FollowSymLinks
            # AllowOverride controls what directives may be placed in .htaccess files.
            # It can be "All", "None", or any combination of the keywords:
            #   Options FileInfo AuthConfig Limit

            AllowOverride all
            Order allow,deny
            Allow from all
        </Directory>

重啟Apache.

2、在入口檔案index.php同級目錄中,放入一個.htaccess 內容如下:

(技巧如果自己編寫建立一個點.開頭的檔案可以使用記事本另存為的方式輸入雙引號".htaccess"儲存即可)
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
    </IfModule>


3、配置索引頁 \application\config\config.php

    原: $config['index_page'] = 'index.php';  

    修改成:$config['index_page'] = '';

轉:https://blog.csdn.net/itechzero/article/details/74852339