我想像这样删除URL上的index.php
。我使用XAMPP。
localhost/3g_admin/home
首先,我在我的codeigniter 3.0.0版本上使用了这个.htaccess
,它工作得很好。
RewriteEngine on
RewriteBase /3G_admin
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
但是当我在3.0.6版本的CodeIgniter上使用这个.htaccess
时,我需要声明这个
localhost/3g_admin/index.php/home
我已经将config.php
设置为此。
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
仍然没有运气。
我在这里做错了什么?
在config.php
中,更改
$config['index_page'] = 'index.php';
至
$config['index_page'] = '';
更改配置
$config['uri_protocol'] ="AUTO"
to
$config['uri_protocol'] = "REQUEST_URI"
以及
$config['index_page'] = '';
一些用户可能还需要更新httpd.conf以及其他提到的上述更改
<Directory /var/www/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
我发现哪里做错了。
它是folder
和rewrite base
的声明。
数字优先不允许使用名称。所以我把CCD_ 10换成了CCD_。
命名约定和正确的规则是
步骤1:进入codeigniter文件夹,打开文件config.php并从$config['index_page'] = ''
中删除"index.php"
步骤2:在codeigniter文件夹中创建".htaccess
"文件,并将下面的代码粘贴到中
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
步骤3:查找( $config['uri_protocol'] = "AUTO" )
并替换为( $config['uri_protocol'] = "REQUEST_URI" )
,同时检查($config['enable_query_strings'] = FALSE; )
步骤4:重新启动examplep服务器并检查。。