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

后端 未结 27 1453
盖世英雄少女心
盖世英雄少女心 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条回答
  •  忘了有多久
    2020-11-22 08:08

    I had some big issues with removing the index.php. As a general rule the .htaccess below has been tested on several servers and generally works:

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

    If you don't have any luck with that then the next step is to adjust your config file. Try some of the other URI protocols e.g.

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

    If your still not having any luck try changing the rewrite rule to include your subfolder. This is often a problem if your using a temporary URL on a dev server etc:

    RewriteRule ^(.*)$ /subofolder1/subfolder2/index.php/$1 [L]  
    

    Just play around with these options, one should work. Also, make sure your index file is set to:

    $config['index_page'] = '';
    

    Good luck!

提交回复
热议问题