Я видел несколько вариантов вопроса и попробовал следующее переписать URL-адреса css/js/images/fonts/plugins в моей теме.Простой файл urls wordpress, Twenty Thirteen
Однако я не смог заставить кого-либо из них работать в теме «Двадцать тринадцать». я заставил 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;
}
и пару других с безрезультатно. Может ли кто-нибудь сказать мне, что мне не хватает (код) или куда должен идти этот код?
большое спасибо!
К сожалению, должны быть перечислены, что, как хорошо! Я пробовал это безрезультатно. Я чувствую, что это должна быть ошибка пользователя на моем конце, с точки зрения того, где я размещаю код и так далее. – RMH
ok можете ли вы сказать, какой тип сервера вы используете? linux, windows ?? apache или nginx? а также проверить поддержку сервера mod_rewire? вы получаете какую-то ошибку при этом? –