Remove index.php from url in CodeIgniter 3

前端 未结 6 1605
死守一世寂寞
死守一世寂寞 2020-12-14 13:42

I am doing a project in CodeIgniter 3. I need to remove index.php from url. For that help me to get .htaccess file for CodeIgniter 3 and also where

6条回答
  •  天命终不由人
    2020-12-14 14:40

    Well,

    Here what I did,

    I edited/create ".htaccess" to this

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

    and "app/config/config.php"

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

    and "app/libraries/Template.php"

    define("PATH", base_url()."index.php/");
    define("BASE", base_url());
    

    Cheers!

提交回复
热议问题