내가 문자열 A를 가지고 말 : /CI/index.php?/user/dashboard/
그리고 문자열 B : 어떻게 하나가 일명 /CI/index.php
그들 사이의 공통점을 발견하고 우리 만 http://localhost/CI/index.php?/user/dashboard/
왼쪽되도록 제거 않습니다 PHP를 사용 http://localhost/CI/index.php
차이는
Q
차이는
0
A
답변
1
Mr Bahamondez의 댓글 링크가 자신의 특정 문제에 대해 작동하지 않았습니다.
이 CodeIgniter는 무엇입니까? htaccess rewrites으로 'CI/index.php'를 제거하지 않겠습니까?
나는이 코드가 얽힌 에세이를 해킹했습니다. (늦었습니다 ...) 도움이되기를 바랍니다. 다른 누군가가 더 잘할 것이라고 확신합니다. 물음표가 URL에 다시 나타납니다.
$str1 = "http://localhost/CI/index.php";
$str2 = "/CI/index.php?/user/dashboard/";
// Take the url scheme and host out of the equation
$url_array = parse_url($str1 . $str2);
// store the path
$path = $url_array['path'];
// store the query (anything after a ?)
$query = $url_array['query'];
// Combine and split into an array using '/' as delimiter
$segments = explode("/", $path . $query);
// store the unique keys and filter out any empty values
$new_array = array_unique(array_filter($segments));
var_export($new_array);
결과 :
array (
1 => 'CI',
2 => 'index.php',
5 => 'user',
6 => 'dashboard',
)
당신이 다음
// Hacky rebuild the url
$segment = "";
foreach ($new_array as $seg) {
$segment .= $seg . "/";
}
$new_url = $url_array['scheme'] . "://" . $url_array['host'] . "/" . $segment;
으로 다시 수 http://localhost/CI/index.php/user/dashboard/
index.php를 및 의 index.php을 줄 것이다?은 문제를 일으키지 만, 항상 /CI/index.php이 될 수있는 특정 사례가있는 경우 해킹 할 수 있습니까?
+0
과 같지는 않습니다. 게시 된 사본은 제 방법에 잘 작동합니다. 그러나 나는 정말로 당신의 일에 감사 드리며 조언을받습니다! upvoted – Alex
관련 문제
공통 부분은 항상 A의 시작 부분이고 B의 끝 부분입니까? – Barmar
네,하지만 실제로는 항상 – Alex