doujubeng2942 2015-01-21 12:02
浏览 56

在codeigniter的控制器中重命名了一个方法。 如何使用.htaccess重定向?

After looking in a lot places, finally posting it here.

I have rename a method in codeigniter's controller from classDetails to class-details.

I am using the following code in .htaccess but it did not work

RewriteRule ^classDetails/(.*)$ class-details/$1 [R=301,L]

I have also tried this code in /application/config/routes.php

$route['classDetails'] = 'class-details';

I have also tried

$routes['classDetails'] = 'class-details';

I have even tried using _remap() in codeigniter as follows

public function _remap($method, $params = array()){
switch ($method){
    case 'classDetails':$method='class_details'; break;
};

if (method_exists($this, $method))
{
    return call_user_func_array(array($this, $method), $params);
}
show_404();
}

No matter what I do it goes to 404 page

Where am I doing it wrong?

[EDIT]

my method name is class_details and I am overwriting that in the url using a custom core class called MY_Router.php

  • 写回答

1条回答 默认 最新

  • doujiang9887 2015-01-21 12:08
    关注

    First of all you are not using correct convention for a method name you can use class-details as method name you can use only all small case or camel case for method name otherwise it will never gonna work. you can give your method name as classDetails and in route you have to write something like this

     $routes['class-details'] = '<controllerName>/classDetails';
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line