diff --git a/wp-includes/functions.php b/wp-includes/functions.php index fa6a42c7e..79f63f118 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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 . '/'; - - $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); + $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 . '/'; - if (strstr($query, 'index.php')) { - $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n"; - } else { - $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n"; - } - } + $rules = "\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); - $rules = apply_filters('rewrite_rules', $rules); + if (strstr($query, 'index.php')) { + $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n"; + } else { + $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n"; + } + } + $rules .= "\n"; - return $rules; + $rules = apply_filters('rewrite_rules', $rules); + + return $rules; } function get_posts($args) {