【问题标题】:Codeigniter Form Open How To Remove index.phpCodeigniter 表单打开如何删除 index.php
【发布时间】:2012-09-27 07:58:57
【问题描述】:

在 Codeigniter 中,当我使用 form_open() 函数时,它会将 index.php 添加到 url。
如何删除它?
注意:我使用 htaccess 从 url 中删除了 index.php。

【问题讨论】:

标签: php forms codeigniter


【解决方案1】:

你可以对 form_open() 进行操作,像这样

form_open(base_url().'your_controller_name/function_name');

【讨论】:

  • form_open(base_url('your_controller_name', 'function_name'));实际上会更合适
【解决方案2】:

您没有从 $config['index_page'] = "index.php"; 中删除 index.php

/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
//$config['index_page'] = 'index.php';
 $config['index_page'] = '';

【讨论】:

  • 这个答案应该被接受而不是另一个。另一个需要始终添加 base_url(),而从配置文件中的 var index_page 中删除 index.php 是使用 mod_rewrite 时建议的解决方案。
猜你喜欢
  • 2017-01-31
  • 2021-03-18
  • 2011-07-09
  • 1970-01-01
  • 2011-01-18
  • 1970-01-01
  • 2016-07-26
  • 2012-10-30
  • 2019-04-06
相关资源
最近更新 更多