我从我的网址中删除了index.php,但现在我需要从网址获取一些变量,CI解决方案是更新config.php
$config['uri_protocol'] = "PATH_INFO";
$config['enable_query_strings'] = TRUE;
当我在url中使用index.php时,这项工作非常完美,但我需要它而没有index.php
这是我的httacess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA
任何解决方案? ,thx
答案 0 :(得分:0)
您是否看过Elliot Haughin的CodeIgniter Facebook库?它可能会提供一些关于在Facebook上使用CI的见解。
答案 1 :(得分:0)
我在CI中遇到了同样的问题,所以我编写了这个函数来从$ _SERVER ['REQUEST_URI']变量中获取查询字符串并将其解压缩。
function extract_querystrings() {
$uri = $_SERVER['REQUEST_URI'];
$uri = explode('?',$uri);
if (count($uri)>1) {
foreach($uri AS $ur) {
$ur = explode('&',$ur);
foreach($ur AS $u) {
$u = explode('=',$u);
if ($u[0]=='/') continue;
$this->query_strings[$u[0]] = $this->input->xss_clean($u[1]);
}
}
}
//echo '<pre>',print_r($this->query_strings,true),'</pre>';
}
在我的自定义主控制器的__construct()中调用此函数。
您可以从
修改以下行$this->query_strings[$u[0]] = $this->input->xss_clean($u[1]);
要
$_GET[$u[0]] = $this->input->xss_clean($u[1]);
看看它是否适合你。