Codeigniter 上的重定向在 URL 中包含索引.php以及如何删除


redirect on codeigniter is including index.php in the url and how to remove?

我在登录页面后在我的代码点火器项目中使用了重定向。

喜欢

redirect('profile/edit/1'); 

并且看到一个类似 URL

http://mypreoject.com/index.php/profile/edit/1

并且,我的页面背景图像无法加载。

使用了.htaccess模式写入,所以这不应该发生,我应该得到以下内容。

http://mypreoject.com/profile/edit/1

如果您使用的是 Apache,请在根 Web 目录中放置一个 .htaccess 文件,其中包含以下内容:

RewriteEngine on RewriteCond $1 !^(index'.php|[Javascript / CSS / Image root Folder name(s)]|robots'.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

如果 CI 控制器 -> 操作在两个 url 中都工作正常

http://mypreoject.com/profile/edit/1

http://mypreoject.com/index.php/profile/edit/1

那么.htacces没问题,你应该检查/application/config/config.php index_page

改变

$config['index_page'] = 'index.php';

$config['index_page'] = '';