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

前端 未结 4 1990
醉酒成梦
醉酒成梦 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:59

    if your root folder for project is not root of domain i.e. your website is subdirectory of a domain http://localhost/myproject then you need an additional line in your .htaccess file that is RewriteBase

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

    Also make sure, your config.php is configured as

    $config['base_url'] = 'http://localhost/myproject/';
    $config['index_page'] = '';
    

    And mod_rewrite is enable in apache's config file.

提交回复
热议问题