remove index.php codeigniter

天涯浪子 提交于 2019-12-25 06:45:36

问题


I really can't find a way to make my .htaccess work and eliminate the /index.php/ part from my localhost site's url: http://localhost/ci_intro/index.php/home/

From XAMPP/xamppfiles/htdocs/ci_intro/application/config/ routes.php :

$route['default_controller'] = 'home';
$route['404_override'] = '';

from XAMPP/xamppfiles/htdocs/ci_intro/application/config/ config.php :

$config['base_url'] = 'http://localhost/ci_intro/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

from XAMPP/xamppfiles/etc/ httpd.conf :

LoadModule rewrite_module modules/mod_rewrite.so

 ...

<Directory "/Applications/XAMPP/xamppfiles/htdocs">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Require all granted
</Directory>

mod_rewrite.so is working, I've checked it with a phpinfo()...

from XAMPP/xamppfiles/htdocs/ci_intro/ .htaccess :

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ci_intro/

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>

Any ideas? Please I really need help here, thanks!


回答1:


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

write this in your htaccess
check this link to enable mod_rewrite function of apache setting




回答2:


My guess is you didn't have "AllowOverride All" set for your DocumentRoot object in httpd.conf / apache2.conf



来源:https://stackoverflow.com/questions/20814773/remove-index-php-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!