Codeigniter Redirect - 您提交的URI不允许使用字符 [英] Codeigniter Redirect -- The URI you submitted has disallowed characters
问题描述
当我尝试重定向到其他网站时,收到此错误:
When i'm trying to redirect to other website, i receive this error:
遇到PHP错误
严重性:警告
消息:parse_url(/%22 * * )[function.parse-url]:无法解析URL
Message: parse_url(/%22**) [function.parse-url]: Unable to parse URL
文件名:core / URI.php
Filename: core/URI.php
行号:219
遇到错误
您提交的URI不允许使用字符。
The URI you submitted has disallowed characters.
这是我在URI.php中拥有的所有代码
This is all the code i have in URI.php
private function _detect_uri()
{
if ( ! isset($_SERVER['REQUEST_URI']) OR ! isset($_SERVER['SCRIPT_NAME']))
{
return '';
}
$uri = $_SERVER['REQUEST_URI'];
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
{
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
}
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
{
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
}
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
if (strncmp($uri, '?/', 2) === 0)
{
$uri = substr($uri, 2);
}
$parts = preg_split('#\?#i', $uri, 2);
$uri = $parts[0];
if (isset($parts[1]))
{
$_SERVER['QUERY_STRING'] = $parts[1];
parse_str($_SERVER['QUERY_STRING'], $_GET);
}
else
{
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
if ($uri == '/' || empty($uri))
{
return '/';
}
$uri = parse_url($uri, PHP_URL_PATH);
// Do some final cleaning of the URI and return it
return str_replace(array('//', '../'), '/', trim($uri, '/'));
}
推荐答案
CodeIgniter检查所有 URI
段的不允许的字符。这是通过白名单允许的字符。可以在 $ config ['permitted_uri_chars'] $ c>中的
/system/application/config/config.php
$ c> variable。 permitted_uri_chars
是CodeIgniter在您的URI中接受的字符。默认值设置为类似。
CodeIgniter checks all URI
segments for disallowed characters. This happens by white listing allowed characters. Which ones are allowed can be checked in /system/application/config/config.php
in the $config['permitted_uri_chars']
variable. permitted_uri_chars
are the characters that CodeIgniter accepts in your URI.The default value is set to something like.
$config['permitted_uri_chars'] = 'a-z 0-9~%.:&_\-';
默认情况下只允许这些: az 0-9〜%.: _-
By default only these are allowed: a-z 0-9~%.:_-
留空以允许所有字符 - 但前提是您是疯了。
Leave blank to allow all characters -- but only if you are insane.
%22
适用于。这在
permitted_uri_chars
列表中。
%22
comes for "
.You can add this in permitted_uri_chars
list.
这篇关于Codeigniter Redirect - 您提交的URI不允许使用字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!