Codeigniter can't remove index.php

2019-09-12 11:44发布

i really need help, same as the title, my problem is can't remove index.php in my codeigniter

i had try many .htaccess code like :

// first 
<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /projectFolderName/ --> i already change to my project name

 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>

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

//third
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ – [NC,L]
RewriteRule ^(.*)$ index.php/$1 [NC,L]

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

i had change my config like

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

in some reference in my httd.conf

<Directory />
    AllowOverride All
    Require all denied
</Directory>

i move the .htaccess to main project folder (not in application) but all doesn't work

2条回答
做个烂人
2楼-- · 2019-09-12 12:21

You forget to set base_url in application/config/config.php.Set your base_url.

$config['base_url'] = 'your_url';

In root folder .htaccess

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

And also

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

Working fine here..

查看更多
仙女界的扛把子
3楼-- · 2019-09-12 12:25

That funny, my url: http://localhost/Igniter in my config: $config['base_url'] = 'http://localhost/igniter'; you can be the same me, check url with link "igniter" replace "Igniter'

查看更多
登录 后发表回答