diff --git a/wp-admin/options-permalink.php b/wp-admin/options-permalink.php index 906361e8a8..345a4b067a 100644 --- a/wp-admin/options-permalink.php +++ b/wp-admin/options-permalink.php @@ -227,7 +227,7 @@ $structures = array( index . '/'; ?>

using_index_permalinks() && strpos($redirect['path'], '/index.php/') === false ) - $redirect['path'] = trailingslashit($redirect['path']) . 'index.php/'; + $redirect['path'] = user_trailingslashit( preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/ + if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/' . $wp_rewrite->index . '/') === false ) + $redirect['path'] = trailingslashit($redirect['path']) . $wp_rewrite->index . '/'; if ( !empty( $addl_path ) ) $redirect['path'] = trailingslashit($redirect['path']) . $addl_path; $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; @@ -324,7 +324,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { unset($redirect['port']); // trailing /index.php - $redirect['path'] = preg_replace('|/index.php/*?$|', '/', $redirect['path']); + $redirect['path'] = preg_replace('|/' . preg_quote( $wp_rewrite->index, '|' ) . '/*?$|', '/', $redirect['path']); // Remove trailing spaces from the path $redirect['path'] = preg_replace( '#(%20| )+$#', '', $redirect['path'] ); @@ -345,7 +345,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { // strip /index.php/ when we're not using PATHINFO permalinks if ( !$wp_rewrite->using_index_permalinks() ) - $redirect['path'] = str_replace('/index.php/', '/', $redirect['path']); + $redirect['path'] = str_replace( '/' . $wp_rewrite->index . '/', '/', $redirect['path'] ); // trailing slashes if ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() && !is_404() && (!is_front_page() || ( is_front_page() && (get_query_var('paged') > 1) ) ) ) { diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index de76f45aae..ad66602610 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -1449,13 +1449,13 @@ function get_pagenum_link($pagenum = 1, $escape = true ) { } $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request); - $request = preg_replace( '|^index\.php|i', '', $request); + $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request); $request = ltrim($request, '/'); $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) ) - $base .= 'index.php/'; + $base .= $wp_rewrite->index . '/'; if ( $pagenum > 1 ) { $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' ); diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index df5612d225..4fc614eb83 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -367,7 +367,7 @@ function _wp_menu_item_classes_by_context( &$menu_items ) { $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); $raw_item_url = strpos( $menu_item->url, '#' ) ? substr( $menu_item->url, 0, strpos( $menu_item->url, '#' ) ) : $menu_item->url; $item_url = untrailingslashit( $raw_item_url ); - $_indexless_current = untrailingslashit( preg_replace( '/index.php$/', '', $current_url ) ); + $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); if ( $raw_item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) { $classes[] = 'current-menu-item'; diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php index 486922a3d1..607a23d8c4 100644 --- a/wp-includes/rewrite.php +++ b/wp-includes/rewrite.php @@ -315,7 +315,7 @@ function url_to_postid($url) { // Strip 'index.php/' if we're not using path info permalinks if ( !$wp_rewrite->using_index_permalinks() ) - $url = str_replace('index.php/', '', $url); + $url = str_replace( $wp_rewrite->index . '/', '', $url ); if ( false !== strpos($url, home_url()) ) { // Chop off http://domain.com