Codeigniter无法删除index.php

时间:2017-01-29 01:39:19

标签: php apache .htaccess codeigniter

我真的需要帮助, 与标题相同,我的问题是无法在我的codeigniter

中删除index.php

我尝试了很多.htaccess代码,如:

// 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]

我改变了我的配置,如

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

在一些参考文献中 在我的httd.conf中

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

我将.htaccess移动到主项目文件夹(不在应用程序中) 但一切都不起作用

2 个答案:

答案 0 :(得分:0)

您忘了在base_url中设置application/config/config.php。设置base_url

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

在根文件夹.htaccess

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

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

在这里工作正常..

答案 1 :(得分:0)

好笑, 我的网址:http://localhost/Igniter 在我的配置中: $ config ['base_url'] ='http://localhost/igniter'; 您可以和我一样,用链接“ igniter”检查url替换“ Igniter”