mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
If we attempt path info matching but do not match, set 404. Also, retabify some code.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1697 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
75d974639b
commit
0cdc3aaff5
@ -14,67 +14,70 @@ $query_vars = array();
|
|||||||
if ((isset($_GET['error']) && $_GET['error'] == '404') ||
|
if ((isset($_GET['error']) && $_GET['error'] == '404') ||
|
||||||
(! empty( $_SERVER['PATH_INFO']))) {
|
(! empty( $_SERVER['PATH_INFO']))) {
|
||||||
|
|
||||||
// Fetch the rewrite rules.
|
// If we match a rewrite rule, this will be cleared.
|
||||||
$rewrite = rewrite_rules('matches');
|
$error = '404';
|
||||||
|
|
||||||
if (! empty($rewrite)) {
|
// Fetch the rewrite rules.
|
||||||
$pathinfo = $_SERVER['PATH_INFO'];
|
$rewrite = rewrite_rules('matches');
|
||||||
$req_uri = $_SERVER['REQUEST_URI'];
|
|
||||||
$home_path = parse_url(get_settings('home'));
|
|
||||||
$home_path = $home_path['path'];
|
|
||||||
|
|
||||||
// Trim path info from the end and the leading home path from the
|
if (! empty($rewrite)) {
|
||||||
// front. For path info requests, this leaves us with the requesting
|
$pathinfo = $_SERVER['PATH_INFO'];
|
||||||
// filename, if any. For 404 requests, this leaves us with the
|
$req_uri = $_SERVER['REQUEST_URI'];
|
||||||
// requested permalink.
|
$home_path = parse_url(get_settings('home'));
|
||||||
$req_uri = str_replace($pathinfo, '', $req_uri);
|
$home_path = $home_path['path'];
|
||||||
$req_uri = str_replace($home_path, '', $req_uri);
|
|
||||||
$req_uri = trim($req_uri, '/');
|
|
||||||
$pathinfo = trim($pathinfo, '/');
|
|
||||||
|
|
||||||
// The requested permalink is in $pathinfo for path info requests and
|
// Trim path info from the end and the leading home path from the
|
||||||
// $req_uri for other requests.
|
// front. For path info requests, this leaves us with the requesting
|
||||||
if (! empty($pathinfo)) {
|
// filename, if any. For 404 requests, this leaves us with the
|
||||||
$request = $pathinfo;
|
// requested permalink.
|
||||||
} else {
|
$req_uri = str_replace($pathinfo, '', $req_uri);
|
||||||
$request = $req_uri;
|
$req_uri = str_replace($home_path, '', $req_uri);
|
||||||
}
|
$req_uri = trim($req_uri, '/');
|
||||||
|
$pathinfo = trim($pathinfo, '/');
|
||||||
|
|
||||||
// Look for matches.
|
// The requested permalink is in $pathinfo for path info requests and
|
||||||
$request_match = $request;
|
// $req_uri for other requests.
|
||||||
foreach ($rewrite as $match => $query) {
|
if (! empty($pathinfo)) {
|
||||||
// If the requesting file is the anchor of the match, prepend it
|
$request = $pathinfo;
|
||||||
// to the path info.
|
} else {
|
||||||
|
$request = $req_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look for matches.
|
||||||
|
$request_match = $request;
|
||||||
|
foreach ($rewrite as $match => $query) {
|
||||||
|
// If the requesting file is the anchor of the match, prepend it
|
||||||
|
// to the path info.
|
||||||
if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
|
if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) {
|
||||||
$request_match = $req_uri . '/' . $request;
|
$request_match = $req_uri . '/' . $request;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match("!^$match!", $request_match, $matches)) {
|
if (preg_match("!^$match!", $request_match, $matches)) {
|
||||||
// Got a match.
|
// Got a match.
|
||||||
// Trim the query of everything up to the '?'.
|
// Trim the query of everything up to the '?'.
|
||||||
$query = preg_replace("!^.+\?!", '', $query);
|
$query = preg_replace("!^.+\?!", '', $query);
|
||||||
|
|
||||||
// Substitute the substring matches into the query.
|
// Substitute the substring matches into the query.
|
||||||
eval("\$query = \"$query\";");
|
eval("\$query = \"$query\";");
|
||||||
|
|
||||||
// Parse the query.
|
// Parse the query.
|
||||||
parse_str($query, $query_vars);
|
parse_str($query, $query_vars);
|
||||||
|
|
||||||
// If we're processing a 404 request, clear the error var
|
// If we're processing a 404 request, clear the error var
|
||||||
// since we found something.
|
// since we found something.
|
||||||
if (isset($_GET['error'])) {
|
if (isset($_GET['error'])) {
|
||||||
unset($_GET['error']);
|
unset($_GET['error']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($error)) {
|
||||||
|
unset($error);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (isset($error)) {
|
}
|
||||||
unset($error);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'error');
|
$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'error');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user