通过htaccess + Codeigniter传递GET参数 [英] Passing GET parameters through htaccess + Codeigniter

查看:64
本文介绍了通过htaccess + Codeigniter传递GET参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将CodeIgniter Framework与该.htaccess命令一起用于漂亮的网址".

I am using CodeIgniter Framework with this .htaccess command for "nice urls".

RewriteCond $1 !^(index\.php|assets|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?$1 [L]

所有网址,例如:

  • example.com/admin/xxx/
  • 以-> example.com/index.php?admin/xxx/传递(看起来像CodeIgniter的?/class/method/)
  • example.com/admin/xxx/
  • passed as -> example.com/index.php?admin/xxx/ (look like CodeIgniter's ?/class/method/)

但是问题是:如何通过$_GET参数?例如:

But question is: How can I pass $_GET paramaters? For Example:

  • example.com/admin/xxx/?action=die&time=now

我需要在外部ajax脚本中使用GET参数(例如:基于CODEIGNTER的ElFinder)

I need use GET params od external ajax scripts (f.e.: ElFinder based on CODEIGNTER)

感谢您的建议



我只是在Elfinder中使用POST方法解决了这个问题: Elfinder-请求类型
但是顺便说一句,在codeigniter中使用$ _GET参数标记为?"有了.htaccess,这是不可能的



I solved this problem just using POST method at Elfinder: Elfinder - Request type
But btw using $_GET params in codeigniter with mark "?" with this .htaccess, is impossible

推荐答案

您是否已阅读它说明了您如何可以通过您的actiontime参数.

It explains how you could pass through your action and time parameters.

例如example.com/admin/xxx/die/now将与Controller

class Admin extends CI_Controller {

    public function xxx($action, $time) {
        // Stuff
    }

}

或者,按照@ War10ck的建议,您可以使用 Input 类以获取必需的$_GET参数.例如

Alternatively as @War10ck suggested you could Use the Input class to get the required $_GET parameters. e.g.

class Admin extends CI_Controller {

    public function xxx() {

        $action = $this->input->get('action');
        $time = $this->input->get('time');

    }

}

这篇关于通过htaccess + Codeigniter传递GET参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆