2014-02-07 87 views
0

我已經看到了問題的多個版本,並曾嘗試以下重寫的CSS/JS /圖像/字體/插件的網址在我的主題。簡單的文件URL的WordPress,二十十三

但是我一直沒能得到任何他們在二十十三主題工作。 我已經迫使htcaccess顯示,沒有運氣

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteRule ^css/(.*) /wp-content/themes/dfi/css/$1 [QSA,L] 
RewriteRule ^images/(.*) /wp-content/themes/dfi/images/$1 [QSA,L] 
RewriteRule ^fonts/(.*) /wp-content/themes/dfi/fonts/$1 [QSA,L] 
RewriteRule ^js/(.*) /wp-content/themes/dfi/js/$1 [QSA,L] 
RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

我在functions.php文件在我的主題

// rewrite /wp-content/themes/theme-name/css/ to /css/ 
// rewrite /wp-content/themes/theme-name/js/ to /js/ 
// rewrite /wp-content/themes/theme-name/img/ to /img/ 
// rewrite /wp-content/plugins/ to /plugins/ 

function roots_flush_rewrites() { 
    global $wp_rewrite; 
    $wp_rewrite->flush_rules(); 
} 

function roots_add_rewrites($content) { 
    $theme_name = next(explode('/themes/', get_stylesheet_directory())); 
    global $wp_rewrite; 
    $roots_new_non_wp_rules = array(
    'css/(.*)'  => 'wp-content/themes/'. $theme_name . '/css/$1', 
    'js/(.*)'  => 'wp-content/themes/'. $theme_name . '/js/$1', 
    'img/(.*)'  => 'wp-content/themes/'. $theme_name . '/img/$1', 
    'plugins/(.*)' => 'wp-content/plugins/$1' 
); 
    $wp_rewrite->non_wp_rules += $roots_new_non_wp_rules; 
} 

add_action('admin_init', 'roots_flush_rewrites'); 

function roots_clean_assets($content) { 
    $theme_name = next(explode('/themes/', $content)); 
    $current_path = '/wp-content/themes/' . $theme_name; 
    $new_path = ''; 
    $content = str_replace($current_path, $new_path, $content); 
    return $content; 
} 

function roots_clean_plugins($content) { 
    $current_path = '/wp-content/plugins'; 
    $new_path = '/plugins'; 
    $content = str_replace($current_path, $new_path, $content); 
    return $content; 
} 

和一對夫婦與其他人沒有用試過這下面。任何人都可以告訴我我缺少什麼(代碼)或代碼應該放在哪裏?

非常感謝!

回答

0

嘗試此解決方案:: http://www.hongkiat.com/blog/wordpress-url-rewrite/

如果您正在使用的根啓動主題來看看這個插件太http://roots.io/plugins/roots-rewrites/

+0

對不起應該已經列出了的!我試圖無濟於事。我覺得在我的代碼放置位置等方面,這肯定是用戶錯誤。 – RMH

+0

好的,你能告訴mw你正在使用什麼類型的服務器? linux,windows? apache或nginx?並檢查你的服務器支持mod_rewire?你在做這件事時會遇到什麼樣的錯誤? –

相關問題