Parse REQUEST_URI as a permalink if it looks permalinkish. Use reduced mod_rewrite rules by default.
git-svn-id: http://svn.automattic.com/wordpress/trunk@2635 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a08b652698
commit
8f00d317de
|
@ -626,9 +626,10 @@ class WP_Query {
|
||||||
$this->queried_object_id = 0;
|
$this->queried_object_id = 0;
|
||||||
|
|
||||||
if ($this->is_category) {
|
if ($this->is_category) {
|
||||||
$category = &get_category($this->get('cat'));
|
$cat = $this->get('cat');
|
||||||
|
$category = &get_category($cat);
|
||||||
$this->queried_object = &$category;
|
$this->queried_object = &$category;
|
||||||
$this->queried_object_id = $this->get('cat');
|
$this->queried_object_id = $cat;
|
||||||
} else if ($this->is_single) {
|
} else if ($this->is_single) {
|
||||||
$this->queried_object = $this->post;
|
$this->queried_object = $this->post;
|
||||||
$this->queried_object_id = $this->post->ID;
|
$this->queried_object_id = $this->post->ID;
|
||||||
|
@ -753,6 +754,7 @@ class WP_Rewrite {
|
||||||
var $index = 'index.php';
|
var $index = 'index.php';
|
||||||
var $matches = '';
|
var $matches = '';
|
||||||
var $rules;
|
var $rules;
|
||||||
|
var $use_verbose_rules = false;
|
||||||
var $rewritecode =
|
var $rewritecode =
|
||||||
array(
|
array(
|
||||||
'%year%',
|
'%year%',
|
||||||
|
@ -1219,29 +1221,37 @@ class WP_Rewrite {
|
||||||
$rules = "<IfModule mod_rewrite.c>\n";
|
$rules = "<IfModule mod_rewrite.c>\n";
|
||||||
$rules .= "RewriteEngine On\n";
|
$rules .= "RewriteEngine On\n";
|
||||||
$rules .= "RewriteBase $home_root\n";
|
$rules .= "RewriteBase $home_root\n";
|
||||||
$this->matches = '';
|
|
||||||
$rewrite = $this->rewrite_rules();
|
|
||||||
$num_rules = count($rewrite);
|
|
||||||
$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
|
|
||||||
"RewriteCond %{REQUEST_FILENAME} -d\n" .
|
|
||||||
"RewriteRule ^.*$ - [S=$num_rules]\n";
|
|
||||||
|
|
||||||
foreach ($rewrite as $match => $query) {
|
if ($this->use_verbose_rules) {
|
||||||
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
|
$this->matches = '';
|
||||||
$match = str_replace('.+?', '.+', $match);
|
$rewrite = $this->rewrite_rules();
|
||||||
|
$num_rules = count($rewrite);
|
||||||
|
$rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
|
||||||
|
"RewriteCond %{REQUEST_FILENAME} -d\n" .
|
||||||
|
"RewriteRule ^.*$ - [S=$num_rules]\n";
|
||||||
|
|
||||||
// If the match is unanchored and greedy, prepend rewrite conditions
|
foreach ($rewrite as $match => $query) {
|
||||||
// to avoid infinite redirects and eclipsing of real files.
|
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
|
||||||
if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
|
$match = str_replace('.+?', '.+', $match);
|
||||||
//nada.
|
|
||||||
}
|
// If the match is unanchored and greedy, prepend rewrite conditions
|
||||||
|
// to avoid infinite redirects and eclipsing of real files.
|
||||||
if (strstr($query, $this->index)) {
|
if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
|
||||||
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
|
//nada.
|
||||||
} else {
|
}
|
||||||
$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
|
|
||||||
|
if (strstr($query, $this->index)) {
|
||||||
|
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
|
||||||
|
} else {
|
||||||
|
$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
|
||||||
|
"RewriteCond %{REQUEST_FILENAME} !-d\n" .
|
||||||
|
"RewriteRule . {$home_root}{$this->index}\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$rules .= "</IfModule>\n";
|
$rules .= "</IfModule>\n";
|
||||||
|
|
||||||
$rules = apply_filters('mod_rewrite_rules', $rules);
|
$rules = apply_filters('mod_rewrite_rules', $rules);
|
||||||
|
@ -1303,12 +1313,16 @@ class WP {
|
||||||
if (! empty($extra_query_vars))
|
if (! empty($extra_query_vars))
|
||||||
parse_str($extra_query_vars, $extra_query_vars);
|
parse_str($extra_query_vars, $extra_query_vars);
|
||||||
|
|
||||||
// Process PATH_INFO and 404.
|
// Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
|
||||||
if ((isset($_GET['error']) && $_GET['error'] == '404') ||
|
if ((isset($_GET['error']) && $_GET['error'] == '404') ||
|
||||||
((! empty($_SERVER['PATH_INFO'])) &&
|
((! empty($_SERVER['PATH_INFO'])) &&
|
||||||
('/' != $_SERVER['PATH_INFO']) &&
|
('/' != $_SERVER['PATH_INFO']) &&
|
||||||
(false === strpos($_SERVER['PATH_INFO'], '.php'))
|
(false === strpos($_SERVER['PATH_INFO'], '.php'))
|
||||||
)) {
|
) ||
|
||||||
|
(empty($_SERVER['QUERY_STRING']) &&
|
||||||
|
(false === strpos($_SERVER['REQUEST_URI'], '.php')) &&
|
||||||
|
('/' != $_SERVER['REQUEST_URI']))
|
||||||
|
) {
|
||||||
|
|
||||||
$this->did_permalink = true;
|
$this->did_permalink = true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue