Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter重定向不带index.php_Php_.htaccess_Codeigniter - Fatal编程技术网

Codeigniter重定向不带index.php

Codeigniter重定向不带index.php,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我在WAMP中使用codeigniter 2.4。每次我设置$config['index\u page']='',codeigniter都找不到控制器方法。当我将其设置回$config['index\u page']='index.php'时,它可以再次找到该方法。我想去掉index.php,这样我的ajax调用就可以正常工作 以下是我的配置文件: **.htaccess:** RewriteEngine on RewriteBase /mca-backend RewriteCond $1

我在WAMP中使用codeigniter 2.4。每次我设置
$config['index\u page']=''
,codeigniter都找不到控制器方法。当我将其设置回
$config['index\u page']='index.php'
时,它可以再次找到该方法。我想去掉
index.php
,这样我的ajax调用就可以正常工作

以下是我的配置文件:

**.htaccess:**

RewriteEngine on 
RewriteBase /mca-backend
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

**config.php**

$config['index_page'] = '';
我有一个类将请求重定向到另一个类方法,下面是代码:

redirect('auth/login', 'refresh');
当重定向代码被调用时就会发生这种情况,我非常确定我的WAMP apache上的
重写\u模块
处于启用状态


有人能帮我吗?非常感谢。

您应该在routes.php中定义您的默认控制器。

您可以在不使用htaccess的情况下使用site\u url代替base\u url来执行此操作,无论您在何处使用重定向。您想在重定向时在url中添加index.php吗?您好,Mitul。不,我想把它处理掉。但是如果我在$config['index_page']中去掉它,codigniter就找不到我的控制器,这意味着mod_重写无法工作。谢谢你,你错过了基地的尾随斜线。您是否已设置了
基本url()
?尝试使用
.htaccess
文件。已将其修复。非常感谢。