Codeigniter - how to remove the index.php from url?

前端 未结 4 1988
醉酒成梦
醉酒成梦 2021-01-05 14:03

I have following structure of my project

/system
/applications
  /cache
  /core
  /helpers
  /hook
  /language
  /libraries
  /logs
  /third_party
  /admin-p         


        
4条回答
  •  孤街浪徒
    2021-01-05 14:37

    Open config.php from system/application/config directory

    and replace

    $config['index_page'] = “index.php” by $config['index_page'] = “”

    Create a “.htaccess” file in the root of CodeIgniter directory

    and add the following lines.

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

    In some case the default setting for uri_protocol does not work properly.

    To solve this problem just replace

    `$config['uri_protocol'] = “AUTO”` 
    

    by

     $config['uri_protocol'] = “REQUEST_URI” 
    

    from system/application/config/config.php

提交回复
热议问题