How to remove “index.php” in codeigniter's path

后端 未结 27 1762
盖世英雄少女心
盖世英雄少女心 2020-11-22 07:17

How do I remove the \"index.php\" sticking out in every path in codeigniter somewhere in the center? I want clean non index.php-fied URLs?

27条回答
  •  青春惊慌失措
    2020-11-22 08:04

    Look in the \application\config\config.php file, there is a variable named index_page

    It should look like this

    $config['index_page'] = "index.php";
    

    change it to

    $config['index_page'] = "";
    

    Then as mentioned you also need to add a rewrite rule to the .htaccess file like this:

    RewriteEngine on
    RewriteCond $1 !^(index\\.php|resources|robots\\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    

    It work for me, hope you too.

提交回复
热议问题