diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 44a776d613..537cb53eb4 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1163,6 +1163,23 @@ function remove_action($tag, $function_to_remove, $priority = 10) { remove_filter($tag, $function_to_remove, $priority); } +function using_mod_rewrite($permalink_structure = '') { + if (empty($permalink_structure)) { + $permalink_structure = get_settings('permalink_structure'); + + if (empty($permalink_structure)) { + return false; + } + } + + // If the index is not in the permalink, we're using mod_rewrite. + if (! preg_match('#^/*' . get_settings('blogfilename') . '#', $permalink_structure)) { + return true; + } + + return false; +} + function preg_index($number, $matches = '') { $match_prefix = '$'; $match_suffix = ''; @@ -1251,9 +1268,9 @@ function generate_rewrite_rules($permalink_structure = '', $matches = '') { $num_tokens = count($tokens[0]); - $index = 'index.php'; - $feedindex = 'index.php'; - $trackbackindex = 'index.php'; + $index = get_settings('blogfilename');; + $feedindex = $index; + $trackbackindex = $index; for ($i = 0; $i < $num_tokens; ++$i) { if (0 < $i) { $queries[$i] = $queries[$i - 1] . '&'; @@ -1334,7 +1351,7 @@ function rewrite_rules($matches = '', $permalink_structure = '') { $front = substr($permalink_structure, 0, strpos($permalink_structure, '%')); $index = get_settings('blogfilename'); $prefix = ''; - if (preg_match('#^/*' . $index . '#', $front)) { + if (! using_mod_rewrite($permalink_structure)) { $prefix = $index . '/'; } diff --git a/wp-includes/template-functions-links.php b/wp-includes/template-functions-links.php index e64882cf84..f1c475b522 100644 --- a/wp-includes/template-functions-links.php +++ b/wp-includes/template-functions-links.php @@ -349,8 +349,14 @@ function get_pagenum_link($pagenum = 1){ $permalink = 1; // If it's not a path info permalink structure, trim the index. - if ( ! preg_match('#^/*' . get_settings('blogfilename') . '#', get_settings('permalink_structure'))) { + if (using_mod_rewrite()) { $qstr = preg_replace("#/*" . get_settings('blogfilename') . "/*#", '/', $qstr); + } else { + // If using path info style permalinks, make sure the index is in + // the URI. + if (! strstr($qstr, get_settings('blogfilename'))) { + $qstr = '/' . get_settings('blogfilename') . $qstr; + } } $qstr = trailingslashit($qstr) . $page_modstring . $pagenum;