[英].htaccess rewrite Wordpress category to page
我對URL結構有一些問題,因為我正在使用我的Wordpress頁面的自定義結構。
目前我使用普通頁面作為類別。
www.domain.tld/my_page
此頁面包含來自普通Wordpress類別的所有帖子。 頁面是使用插件自動生成的。 我的問題是當我使用面包屑時,當我進入帖子時,我得到以下面包屑。
Home > Category > Post
這應該是
Home > Category > Post (where category should link to my_page instead of category)
我可以使用.htaccess中的正常重寫來管理它,如下所示:
RewriteRule ^category/name_of_category/ http://domain.tld/name_of_category/ [R=301,L]
是否可以在.htaccess中進行重寫,從URL結構中刪除/類別/完全? 這將使我的結構按照應有的方式工作,而不必每次在新類別中都使用.htaccess中的新規則。
希望有人能提供幫助。
function kill_category_base ($string) {
$string = str_replace('category/', '', $string);
return $string;
}
add_filter('category_link', 'kill_category_base');
RewriteRule ^([^/.]+)/(page/([0-9]+)|feed)$ index.php/category/$1/$2 [L] # redirect category pages and feeds
在此處找到刪除分類后綴永久鏈接
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.