的.htaccess重写字preSS类别页面 [英] .htaccess rewrite Wordpress category to page

查看:172
本文介绍了的.htaccess重写字preSS类别页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个URL结构一点一点改进,因为我用我的话语preSS页的自定义结构。

目前我使用正常的页面作为类别。

 是www.domain.tld / my_page

该网页包含从普通的Word preSS类别的所有讯息。页面自动生成与插件。当我使用面包,当我进入后,我得到下面的面包屑我的问题是。

 首页>分类>岗位

这应该是

 首页>分类>帖子(其中类别应该链接到my_page而不是类)

我可以在这样的.htaccess正常rewritetrule管理这样的:

 重写规则^类/ name_of_category / HTTP://domain.tld/name_of_category/ [R = 301,L]

时有可能使rewritetule在.htaccess,消除/分类/完全从URL strucure?这将使我的工作结构像它应该,而不必在.htaccess每次我的广告新的类别。

广告新规则我

希望有人可以提供帮助。


解决方案

函数kill_category_base($字符串){
   $字符串= str_replace函数(类别/','',$字符串);
   返回字符串$;
}
的add_filter('category_link','kill_category_base');

重写规则^([^ /] +)/(页/([0-9] +)|供稿) $的index.php /分类/ $ 1 / $ 2 [L]#重定向类别页面和饲料

在这里找到删除CATEGORIY后缀永久

I have a little problen with URL structure because i am using a custom structure of my Wordpress page.

Currently i am using normal pages as categories.

www.domain.tld/my_page

This page contains all posts from a normal Wordpress category. Page is autogenerated with plugin. My problem is when i am using breadcrumbs, when i go into post i get following breadcrumbs.

Home > Category > Post

This should be

Home > Category > Post (where category should link to my_page instead of category)

I can manage this with normal rewritetrule in .htaccess like this:

RewriteRule ^category/name_of_category/ http://domain.tld/name_of_category/ [R=301,L]

Is is possible to make rewritetule in .htaccess that removes /category/ completely from URL strucure? This will make my structure work like it should, without me having to ad new rule in .htaccess everytime i ad new category.

Hope someone can help.

解决方案

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

Found here Remove Categoriy Suffix Permalink

这篇关于的.htaccess重写字preSS类别页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆