2014-11-25 48 views
0

這是我的代碼:(使用默認的WP主題:twentyfourteen)WordPress的重寫non_wp_rules

function my_rewrite_rules($wp_rewrite) { 
    $non_wp_rules = array(
     'assets/(.*)' => 'wp-content/themes/twentyfourteen/assets/$1', 
    ); 

    $wp_rewrite->non_wp_rules = $non_wp_rules + $wp_rewrite->non_wp_rules; 
} 

function my_flush_rewrite_rules() { 
    global $wp_rewrite; 

    $wp_rewrite->flush_rules(); 
} 

add_action('init', 'my_flush_rewrite_rules'); 
add_action('generate_rewrite_rules', 'my_rewrite_rules'); 

現在,我訪問鏈接:

mysite.domain/wp-content/themes/twentyfourteen/assets/css/global.css => //yes, base css file 
mysite.domain/assets/css/global.css => //not working 

有人能幫助我嗎?

回答

0

您需要調整重寫規則略有

$non_wp_rules = array(
    'css/(.*)' => 'wp-content/themes/twentyfourteen/assets/css/$1', 
    'js/(.*)' => 'wp-content/themes/twentyfourteen/assets/js/$1', 
);