Remove index.php in codeigniter 2.1.0

前端 未结 9 1743
渐次进展
渐次进展 2020-11-29 05:10

I tried everything on google related to removing index.php from URL in codeigniter but no solution worked for me I am using codeigniter version 2.1.0 How I can remove index

9条回答
  •  旧巷少年郎
    2020-11-29 05:20

    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_page']   = '';
    |
    | '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

提交回复
热议问题