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

后端 未结 27 1959
盖世英雄少女心
盖世英雄少女心 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:00

    Have the.htaccess file in the application root directory, along with the index.php file. (Check if the htaccess extension is correct , Bz htaccess.txt did not work for me.)

    And Add the following rules to .htaccess file,

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]  
    

    Then find the following line in your application/config/config.php file

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

    Set the variable empty as below.

    $config['index_page'] = '';
    

    That's it, it worked for me.

    If it doesn't work further try to replace following variable with these parameters ('AUTO', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_URI', and 'ORIG_PATH_INFO') one by one

    $config['uri_protocol'] = 'AUTO';
    

提交回复
热议问题