How to remove “index.php” in codeigniter's path

后端 未结 27 1464
盖世英雄少女心
盖世英雄少女心 2020-11-22 07:17

How do I remove the \"index.php\" sticking out in every path in codeigniter somewhere in the center? I want clean non index.php-fied URLs?

27条回答
  •  旧时难觅i
    2020-11-22 08:12

    i tested this on apache2 on many different hosting and it works great.

    use this htaccess

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

    be sure you have enabled mod_rewirte with a phpinfo();

    then do this in config/config.php:

    $config['index_url']    = '';
    |
    | 'AUTO'            Default - auto detects
    | 'PATH_INFO'       Uses the PATH_INFO
    | 'QUERY_STRING'    Uses the QUERY_STRING
    | 'REQUEST_URI'     Uses the REQUEST_URI
    | 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO
    |
    */
    $config['uri_protocol'] = 'AUTO';
    

    if it doesn't works yet, try to change the $config['uri_protocol']='AUTO' to one of the listed inside application/config/config.php file on line 40/54:

    sometimes i used : REQUEST_URI instead of AUTO or "QUERY_STRING" for goDaddy hostings

提交回复
热议问题