我想要将属于名为症状的类别的所有子类别重定向到同一个页面。
我做了这个:
RewriteRule ^category/symptoms/(.*)$ https://my-site/com/list/$1 [L,R=301]
Wordpress重定向,但始终在末尾添加子类别。例如:my-site/com/category/symptoms/fever
被重定向到my-site/com/list/fever
。
如何停止添加子类别?
发布于 2018-10-03 11:02:12
$1
正在从(.*)$
获取值,因此要删除子类别,需要删除标志
RewriteRule ^category/symptoms/(.*)$ https://my-site/com/list/ [L,R=301]
发布于 2018-10-03 11:42:59
如果我正确地回答了你的问题,你想把所有的https://my-site.com/category/symptoms/[subcategory]
重定向到https://my-site.com/list/
,对吗?
只要做:
RewriteRule ^category/symptoms/.*$ https://my-site/com/list/ [L,R=301]
这将替换从category/symptoms/
到行尾的所有内容(用$
标记)。
您的symptoms/(.*)$
保存了pattern/
和行尾之间的所有内容,并在替换字符串中替换了$1
。
有关正则表达式中替换字符串的引用,请参阅本教程:https://www.regular-expressions.info/replacebackref.html
https://wordpress.stackexchange.com/questions/315773
复制相似问题