Wrap rewrite rules in IfModule. Bug 318.
git-svn-id: http://svn.automattic.com/wordpress/trunk@1721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
71ee7bb747
commit
f16701674d
|
@ -1420,31 +1420,33 @@ function rewrite_rules($matches = '', $permalink_structure = '') {
|
|||
}
|
||||
|
||||
function mod_rewrite_rules ($permalink_structure) {
|
||||
$site_root = str_replace('http://', '', trim(get_settings('siteurl')));
|
||||
$site_root = preg_replace('|([^/]*)(.*)|i', '$2', $site_root);
|
||||
if ('/' != substr($site_root, -1)) $site_root = $site_root . '/';
|
||||
$site_root = str_replace('http://', '', trim(get_settings('siteurl')));
|
||||
$site_root = preg_replace('|([^/]*)(.*)|i', '$2', $site_root);
|
||||
if ('/' != substr($site_root, -1)) $site_root = $site_root . '/';
|
||||
|
||||
$home_root = str_replace('http://', '', trim(get_settings('home')));
|
||||
$home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
|
||||
if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
|
||||
$home_root = str_replace('http://', '', trim(get_settings('home')));
|
||||
$home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
|
||||
if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
|
||||
|
||||
$rules = "RewriteEngine On\n";
|
||||
$rules .= "RewriteBase $home_root\n";
|
||||
$rewrite = rewrite_rules('', $permalink_structure);
|
||||
foreach ($rewrite as $match => $query) {
|
||||
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
|
||||
$match = str_replace('.+?', '.+', $match);
|
||||
$rules = "<IfModule mod_rewrite.c>\n";
|
||||
$rules .= "RewriteEngine On\n";
|
||||
$rules .= "RewriteBase $home_root\n";
|
||||
$rewrite = rewrite_rules('', $permalink_structure);
|
||||
foreach ($rewrite as $match => $query) {
|
||||
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
|
||||
$match = str_replace('.+?', '.+', $match);
|
||||
|
||||
if (strstr($query, 'index.php')) {
|
||||
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n";
|
||||
} else {
|
||||
$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n";
|
||||
}
|
||||
}
|
||||
if (strstr($query, 'index.php')) {
|
||||
$rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n";
|
||||
} else {
|
||||
$rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n";
|
||||
}
|
||||
}
|
||||
$rules .= "</IfModule>\n";
|
||||
|
||||
$rules = apply_filters('rewrite_rules', $rules);
|
||||
$rules = apply_filters('rewrite_rules', $rules);
|
||||
|
||||
return $rules;
|
||||
return $rules;
|
||||
}
|
||||
|
||||
function get_posts($args) {
|
||||
|
|
Loading…
Reference in New Issue