duanjing9339 2013-03-21 05:24
浏览 51
已采纳

在url调用时使函数未定义

Using Codeigniter, i call a public function[of my controller] from the url which is basically normal behavior of the framework. I'm passing 3 parameters as $a, $b, $c and as the function gets executed, it checks the parameters and goes according to it. Now, the problem is i do not want my function to be called from the url, when it is called it should go to 404 page. i do know that this can be achieved by adding private or protected, but the real problem is it should be accessed only through one of my own other functions and not by direct url. Any solutions are welcome.

HTTP route block works. But when i pass parameters, the function gets executed which is a security problem. Any idea how to block access?

  • 写回答

2条回答 默认 最新

  • doupao6698 2013-03-21 05:45
    关注

    You could use routing to block any http traffic to that controller/method and redirect to the 404 page.

    In your routes.php file in the config folder, add the following

    $route['controller/private_method'] = '{your 404 controller}';
    $route['controller/private_method/(:any)'] = '{404 controller}';
    

    The second rule caters for any number of parameters.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 速帮,学校需要在外上班没空
  • ¥15 人在外地出差,速帮一点点
  • ¥15 如何使用canvas在图片上进行如下的标注,以下代码不起作用,如何修改
  • ¥15 Windows 系统cmd后提示“加载用户设置时遇到错误”
  • ¥50 vue router 动态路由问题
  • ¥15 关于#.net#的问题:End Function
  • ¥15 无法import pycausal
  • ¥15 VS2022创建MVC framework提示:预安装的程序包具有对缺少的注册表值的引用
  • ¥15 weditor无法连接模拟器Local server not started, start with?
  • ¥20 6-3 String类定义