2015-01-08 73 views
0

我正在使用CodeIgniter框架將此.htaccess命令用於「漂亮的網址」。通過htaccess傳遞GET參數+ Codeigniter

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

所有URL,用於如:

  • example.com/admin/xxx/
  • 如通過 - >example.com/index.php?admin/xxx/(看起來像CodeIgniter的?/class/method/

但問題是:如何傳遞$_GET PARAMATERS ?例如:

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

我需要使用GET PARAMS OD外部AJAX腳本(FE:ElFinder基於CODEIGNTER)

感謝意見


編輯:
我剛剛使用POS解決了這個問題T方法在Elfinder: Elfinder - Request type
但btw使用$ _GET參數codeigniter與標記「?」使用.htaccess,是不可能的

+0

結帳CodeIgniter的['Input'類](https://ellislab.com/codeigniter/user-guide/libraries/input.html)和'$配置['allow_get_array]'在你的配置文件設置。 – War10ck

回答

1

您是否閱讀過關於URI segments的CodeIgniter文檔?

它解釋了你如何可能通過你的actiontime參數。

例如example.com/admin/xxx/die/now將匹配到Controller

class Admin extends CI_Controller { 

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

} 

或者爲@ War10ck建議您可以使用Input類來獲得所需的$_GET參數。例如

class Admin extends CI_Controller { 

    public function xxx() { 

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

    } 

} 
+0

是訪問GET參數是好的,但htaccess重定向被更早觸發,並將我重定向到沒有$ _GET參數的頁面。 – drozdo