Issues in removing index.php in CodeIgniter 3

前端 未结 10 1470
灰色年华
灰色年华 2021-01-13 06:53

I want to access my URL\'s without index.php in CodeIgniter. Here is my Blog controller

class Blog extends CI_Controller {

    pub         


        
10条回答
  •  长情又很酷
    2021-01-13 07:38

    Step:-1 Open the folder “application/config” and open the file “config.php“. find and replace the below code in config.php file.

     //find the below code   
        $config['index_page'] = "index.php" 
        //replace with the below code
        $config['index_page'] = ""
    

    Step:-2 Write below code in .htaccess file

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

    Step:-3 In some case the default setting for uri_protocol does not work properly. To solve this problem just open the file “application/config/config.php“, then find and replace the below code

    //find the below code
    $config['uri_protocol'] = "AUTO"
    //replace with the below code
    $config['uri_protocol'] = "REQUEST_URI" 
    

提交回复
热议问题