Make WordPress Core

Ticket #19876: bare-category-redirect.diff

File bare-category-redirect.diff, 569 bytes (added by duck_, 13 years ago)

PoC hack to redirect http://example.com/uncategorized/

  • wp-includes/canonical.php

     
    426426 *              location on success.
    427427 */
    428428function redirect_guess_404_permalink() {
    429         global $wpdb;
     429        global $wpdb, $wp_rewrite;
    430430
     431        if ( preg_match( '#^[^%]+%category%#', $wp_rewrite->permalink_structure )
     432                && $cat = get_category_by_path( $_SERVER['REQUEST_URI'] )
     433        ) {
     434                return get_term_link( $cat );
     435        }
     436
    431437        if ( !get_query_var('name') )
    432438                return false;
    433439