通过htaccess + Codeigniter传递GET参数

编程入门 行业动态 更新时间:2024-10-05 13:24:33
本文介绍了通过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/admin/xxx/
  • 以-> example/index.php?admin/xxx/传递(看起来像CodeIgniter的?/class/method/)
  • example/admin/xxx/
  • passed as -> example/index.php?admin/xxx/ (look like CodeIgniter's ?/class/method/)

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

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

  • example/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

推荐答案

您是否已阅读 URI分段?

它说明了您如何可以通过您的action和time参数.

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

例如example/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参数

本文发布于:2023-11-02 06:30:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551625.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   htaccess   Codeigniter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!