[英]Wordpress Rewrite Rules Using Capture
I'm trying to make a rewrite rule for d3 visualizations that I'll be keeping in my theme folder. 我正在尝试为将保留在主题文件夹中的d3可视化制定重写规则。 Ultimately I want
最终我想要
d3/[some-year]/[some-string]
to redirect to 重定向到
wp-content/themes/my-theme/d3-library/[some-year]/[some-string]/index.html
However, I can't get the capture rules to work. 但是,我无法使捕获规则起作用。 Here's what I have so far:
这是我到目前为止的内容:
function d3_rewrite() {
add_rewrite_rule(
'wp-content/themes/d3/(20[0-9][0-9]/.*)',
'wp-content/themes/my-theme/assets/d3-library/$match[1]/index.html',
'top'
);
}
add_action('init', 'd3_rewrite');
Does anyone know why this doesn't work? 有谁知道为什么这不起作用?
Use wp-content/themes/my-theme/assets/d3-library/$1/index.html
. 使用
wp-content/themes/my-theme/assets/d3-library/$1/index.html
。 The problem is in the replacement back-reference. 问题出在替换后向引用中。
如果您有$match[1]
,那不应该是$matches[1]
吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.