Remove index.php from url in CodeIgniter 3

前端 未结 6 1604
死守一世寂寞
死守一世寂寞 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:28

    Update your htaccess file with the below code

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

    and in config file, please change base url with below code:-

    $root  = "http://".$_SERVER['HTTP_HOST'];
    $root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
    $config['base_url']    = $root;
    

提交回复
热议问题